I receive a GET variable named $temp in my php code, after connecting to the server and selecting the correct database, and I am able to pass it into the table using:
mysql_query("INSERT INTO Temperature (Temperature) VALUES ($temp)");
However if I save a time variable using:
$time = date('G:i', time());
and try and pas it in with:
mysql_query("INSERT INTO Temperature (Temperature) VALUES ($temp)");
or even:
mysql_query("INSERT INTO Temperature (Time,Temperature) VALUES ($time,$temp)");
I am unable to get it to be passed into my table.
I am echoing both variables so I know they are being saved correctly into the variables. Also, in my table there are two columns named "Time" and "Temperature". The name of the table is "Temperature". Why won't the $time variable get passed in if it is the exact same line of code as $temperature variable except for changing the column name? Also both columns are set to recieve varchar (20) could this be the issue?
mysqli_*orPDOwith prepared Statements.TIMEor sooner or later you will run into inconsistent data.