suttercain Posted November 17, 2009 Share Posted November 17, 2009 Hi everyone, I've spent nearly two hours on this and am going mad. I am trying to do a basic update, which I've done millions of times, but one line of code kicks me out an error. See two slightly different scripts below. The first one works if I take out one column, the second one doesn't work if I attempt to update the column. WORKS: $sql = "UPDATE theater SET ". "Date='".$Date."',". "EventType='".addslashes($EventType)."',". "City='".addslashes($City)."',". "Venue='".addslashes($Venue)."',". "URL='".addslashes($URL)."'". " WHERE id=$id"; DOESN'T WORK $sql = "UPDATE theater SET ". "Date='".$Date."',". "EventType='".addslashes($EventType)."',". "Show='".addslashes($Show)."',". // <--This line prevents it from working... "City='".addslashes($City)."',". "Venue='".addslashes($Venue)."',". "URL='".addslashes($URL)."'". " WHERE id=$id"; The 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 'Show='test',City='City1',Venue='Venue1',URL='Tickets1' WHERE id=2' at line 1 Thanks in advance for the help. Link to comment https://forums.phpfreaks.com/topic/181895-solved-cannot-figure-out-why-this-update-statement-isnt-working/ Share on other sites More sharing options...
Mchl Posted November 17, 2009 Share Posted November 17, 2009 SHOW is reserved word in MySQL http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html and addslashes shouldn't be used to scape data. Use mysql_real_escape_string instead. Link to comment https://forums.phpfreaks.com/topic/181895-solved-cannot-figure-out-why-this-update-statement-isnt-working/#findComment-959338 Share on other sites More sharing options...
suttercain Posted November 17, 2009 Author Share Posted November 17, 2009 SHOW is reserved word in MySQL http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html and addslashes shouldn't be used to scape data. Use mysql_real_escape_string instead. Oh man.. SHOW is a reserved word.. DOH! Thanks so much... agree w/ the addslashes, this is someone else's code and I'm not going to step on their feet Thanks again. Link to comment https://forums.phpfreaks.com/topic/181895-solved-cannot-figure-out-why-this-update-statement-isnt-working/#findComment-959352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.