Arduino 1.0.6 and mysql unable to post varable to mysql

Hi Guys,
Firstly thanks very much for reading this post. I am very new to Arduino, and really like it so far, not had to do programming since my pascal days !

So like others Im trying to log temps using the mega 2560 with Eth Shield. I can read the temps fine and do all the bits I want to about warnings, my next stage is to log the data to a mysql db.

I have setup a mysql db on my workstation, I can connect, read and write data. However Im stuggling with writing the values that I have collected to the db, I just dont know enough about the language yet.

My coding is a bit messy to say the least as im still learning, I have read many books but cannot get my mind past this issue.

So here goes :

This is the line that writes to the mysql
my_conn.cmd_query(“INSERT INTO jeztest.tempsensors (tempreading,tempdate,temptime,tempsensor) VALUES (tempint ,NOW(),NOW(),‘1’)”);

the DB is jeztest and the table is tempsensors, tempreading (The temp from the thermisters), temp date (current date) temp time (Time of the reading) and tempsensor (Sensor number(There are five attached)).

The problem I have is the tempreading (tempint) which is a float (Ignore the name I have been trying everything.

I cannot get the data contained in the tempint into the db, sometimes I get the name of the varable other times nothing.

I have read other posts and still none the wiser, and am hoping someone can help me solve this and explain it to me ? Please dont make fun of the mess I have posted below, but be constructive ??

Many thanks in advance !

I tried to post code here but it exceeds 900 chars so unable so attached it instead

program.txt (14.5 KB)

 sprintf(sqlbuf,"INSERT INTO jeztest.tempsensors (tempreading,tempdate,temptime,tempsensor) VALUES (tempint ,NOW(),NOW(),'1')",tempint);

The first argument is where to write. The second argument is how to format the output. You have NO format specifiers, so the output will ALWAYS be exactly the same string. Rather useless to use sprintf() for that.

Replace tempint in the format part with %d.