Help with a syntax error I can't find in UPDATE query?
Posted: Thu Dec 01, 2011 2:12 am
My browser is displaying the following indication of the error:
[text]Connected to mysql.
Resource id #7You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 ='xxx' WHERE loginName='jellis00 '' at line 1[/text]
It is obviously pointing at the BOLDED statement in below code segment. Can anyone please help me find and explain the error????...I have spent hours studying this problem and any help would be appreciated.
[text]Connected to mysql.
Resource id #7You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 ='xxx' WHERE loginName='jellis00 '' at line 1[/text]
It is obviously pointing at the BOLDED statement in below code segment. Can anyone please help me find and explain the error????...I have spent hours studying this problem and any help would be appreciated.
Code: Select all
<?php
//Store latest temperature reading in appropriate time slot in mysql DB table "temphistory"
mysql_connect("jellis00.db.2694804.hostedresource.com", "jellis00", "password") or die(mysql_error());
echo "<br />Connected to mysql.<br />";
mysql_select_db("jellis00") or die(mysql_error());
// Point to the record for the logged in iChip Serial_no
// Get a specific result from the table that contains the value in $theSerial
$result = mysql_query("SELECT * FROM temphistory
WHERE loginName='jellis00' ") or die(mysql_error());
echo $result ;
mysql_query("UPDATE temphistory SET iChipID= '$theSerial'
WHERE loginName='$loginName' ");
// Determine the hour of the temperature measurement and store measurement in appropiate field
if ($theTime = "00:00"){
[b]mysql_query("UPDATE temphistory SET 0 ='$theTemp' WHERE loginName='$loginName' ") or die(mysql_error());[/b]
} elseif ($theTime = "01:00"){
mysql_query("UPDATE temphistory SET 1 ='$theTemp' WHERE loginName='$loginName' ") or die(mysql_error());
} elseif ($theTime = "02:00"){
mysql_query("UPDATE temphistory SET 2 ='$theTemp' WHERE loginName='$loginName' ") or die(mysql_error());
} elseif ($theTime = "03:00"){
mysql_query("UPDATE temphistory SET 3 ='$theTemp' WHERE loginName='$loginName' ") or die(mysql_error());
// etc, etc, etc
?p>