mySQL database - help

Hi folks!

I really need to ask the experts due to some suspected rookie error on my part (and after trying lots and lots of things for myself for quite a long time) - regarding adding character strings (- just simple ascii string) to a SQL table).

I’ve had success in adding NUMBERS to columns that are formatted as FLOAT.

And I’ve also had success in adding character strings containing ‘numbers’ like “1234” and “5555” etc.

I am using an arduino board to communicate with a web-server (and the web-server handles everything using php script).

My big problem, which I haven’t been able to sort out is described as follows:

I’ve set a column format (eg column #1) to be of a ASCII type (well… I saw the word ‘COLLATION’ in the settings, so I’m assuming it’s important to set something, like ASCII type). Anyway, that’s what I’ve done. Now, when I use the arduino to send a ‘number’ (in text character form), such as “1234567798”, then the SQL table successfully adds this STRING (that involves ‘numbers’ only).

However, if I then decide to pop an alphabetic character inside that string… such as “A1234567798” or “12345R67798” or "“12345XYZWABC67798”, then nothing happens. That is, strings that contain BOTH alphabetic characters and ‘ascii numbers’ aren’t getting added to the table.

So, right now…the table will only add STRINGS like “157” or “566” or “77”, but nothing will happen (ie. not update) if I send strings like “1A5” or “555X12”.

I’m really only just trying to add simple strings to my ascii column. That’s about it really. I’m really getting done-in by rookie error on my part.

If somebody can take a quick glance at my really basic sql database screenshots and/or offer some advice to point me in the right direction, then that would be massively appreciated.

At the moment, my screenshots shows that I’ve set my column #1 to CHAR (with adequate character length). And another screenshot shows that I can successfully add ascii ‘numbers’.

My arduino code for sending “POST method” data works nicely, so that part is ok. So now I’m just using test-strings to try figure out how to add character strings.

Within my webserver-side .php script file, the TEST STRING that I set-up is just like this:

$t1 = "1234588T67";

So… in the above ‘string’, I have included the character ‘T’ toward the end. So that would be an example where the database does nothing if I send it that particular string.

However, the database will at least become alive if I send a string-encoded ‘number’… like…

$t1 = "123458867";

INTERESTINGLY… sending “-1” works too… such as:

$t1 = "-1";

will successfully add a ‘-1’ to the table, as if the column is stuck in a number or float format mode?

And the table inserting/update php code just looks like this:

$sql = "INSERT INTO ardtable (value1, value2, value3, value4) VALUES ($t1, $t2, $t3, $t4)";

Thanks for any help in advance!!




There is usually a "text" option?

Tried having the data as "text" in the mysql table?

Johnny010: There is usually a "text" option?

Tried having the data as "text" in the mysql table?

Hi Johnny! Thanks for your help. I can give that a try.

Just a moment ago, I found out what I was doing wrong .... or rather, I found out what I needed to do to get this database to add a string.

A moment ago, I added SINGLE quotes .... so used this (SUCCESSFULLY).......

$t1 = "'T67'"; So, it is SINGLE quotes within DOUBLE QUOTES!!

I spent a day with fiddling with the sql database format options etc. And only just now stumbled on this.

I'm thinking this (my) approach is probably not the best way to add a string.

I don't know why I need to use single quotes within the double quote to just get things to come alive. At least there's a way to add my strings...... but I'm thinking this is probably not the usual way to do it..... mainly because I didn't think I'd need to include single quotes. I would have expected that the SQL just pick up the string like "abc" and just insert it...... instead of requiring "'abc'".

Thanks for responding before Johnny! Really appreciated it.