Tuk Posted November 22, 2009 Share Posted November 22, 2009 I'm trying to execute an update script when someone presses a button... and it's telling me I have an error with my syntax. I don't see it, so maybe another pair of eyes will help. The update... if (isset($_POST['claimflag'])){ $flaggle = $_POST['retainclaimid']; $duuuude = $_SESSION[id]; $yoursnow = mysql_query("UPDATE flags SET mod = $duuuude WHERE flagid = $flaggle") or die("Error: ".mysql_error()); } And the error I'm getting...: "Error: 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 'mod = 1 WHERE flagid = 3' at line 1" 'claimflag' is the name of the submit button in the form. 'retainclaimid' is a hidden input value in the form, and is linked to the flagid, since the form is looped... 'flagid' is the primary index in the 'flags' table, and 'mod' is an integer in the flags table... Let me know if you need more info. This is driving me insane. Quote Link to comment https://forums.phpfreaks.com/topic/182541-syntax-error/ Share on other sites More sharing options...
LooieENG Posted November 22, 2009 Share Posted November 22, 2009 $yoursnow = mysql_query("UPDATE flags SET mod = '$duuuude' WHERE flagid = '$flaggle'") edit: oh, my bad. missed the mod thing Quote Link to comment https://forums.phpfreaks.com/topic/182541-syntax-error/#findComment-963467 Share on other sites More sharing options...
rajivgonsalves Posted November 22, 2009 Share Posted November 22, 2009 mod is a mysql function you should change the fieldname if possible or quote it in `` $yoursnow = mysql_query("UPDATE flags SET `mod` = '$duuuude' WHERE flagid = $flaggle") Quote Link to comment https://forums.phpfreaks.com/topic/182541-syntax-error/#findComment-963468 Share on other sites More sharing options...
mikesta707 Posted November 22, 2009 Share Posted November 22, 2009 you also don't have a semi colon after this line $yoursnow = mysql_query("UPDATE flags SET mod = $duuuude WHERE flagid = $flaggle") Quote Link to comment https://forums.phpfreaks.com/topic/182541-syntax-error/#findComment-963469 Share on other sites More sharing options...
Tuk Posted November 22, 2009 Author Share Posted November 22, 2009 Thank you for the information, rajivgonsalves -- it worked. Wasn't aware of 'mod' being a function. Thanks! mikesta707 -- that is because I have an or die on the next line. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/182541-syntax-error/#findComment-963470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.