php/SQL syntax error
Posted: Tue Nov 03, 2009 11:30 am
I'm getting an error when my code is ran. The error is:
failed - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on WHERE dam=3546' at line 1
$om_agreement is a checkbox, so the "on" mentioned above means that the box was checked.
If $om_agreement for a dam is checked, then the corresponding dam will be checked in the dam_list table.
I think the message is saying that there is an error in my query, but I don't see it. I could use a fresh set of eyes on this. Thanks.
failed - 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on WHERE dam=3546' at line 1
$om_agreement is a checkbox, so the "on" mentioned above means that the box was checked.
If $om_agreement for a dam is checked, then the corresponding dam will be checked in the dam_list table.
Code: Select all
FOREACH($_POST['om_agreement'] as $row=>$om_agreement)
{
$om_agreement=mysql_real_escape_string($om_agreement);
$dam=mysql_real_escape_string($_POST['dam'][$row]);
$query2="UPDATE dam_list SET om_agreement = $om_agreement WHERE dam=$dam";
if (!mysql_query($query2, $link))
{
die("failed - " . mysql_errno() . ": " .
mysql_error());
}
echo "$line O&M updated";
}