refiking Posted September 24, 2008 Share Posted September 24, 2008 Here's the Error Message: 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 '= Home WHERE sid = '15'' at line 1 $update2 = mysql_query("UPDATE history SET" .$ptid. "= '$title' WHERE sid = '$sid'")or die(mysql_error()); I checked each variable and they all passed with no problem and here is the other query that passed with no problem. To me, they are identical in regard to structure. $update = mysql_query("UPDATE history SET " .$pid. "= '$text' WHERE sid = '$sid'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/125632-solved-sql-syntax-cant-find-the-error/ Share on other sites More sharing options...
Maq Posted September 24, 2008 Share Posted September 24, 2008 Try this: $update2 = mysql_query("UPDATE history SET '" . $ptid . "' = '" . $title . "' WHERE sid = '" . $sid ."'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/125632-solved-sql-syntax-cant-find-the-error/#findComment-649525 Share on other sites More sharing options...
refiking Posted September 24, 2008 Author Share Posted September 24, 2008 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 ''p1title' = 'Home' WHERE sid = '15'' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/125632-solved-sql-syntax-cant-find-the-error/#findComment-649530 Share on other sites More sharing options...
jonsjava Posted September 24, 2008 Share Posted September 24, 2008 <?php $update2 = mysql_query("UPDATE `history` SET `$ptid`='$title' WHERE sid = '$sid';")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/125632-solved-sql-syntax-cant-find-the-error/#findComment-649531 Share on other sites More sharing options...
refiking Posted September 24, 2008 Author Share Posted September 24, 2008 That worked. You inadvertently placed an extra semicolon in the string, but once I removed that it worked perfectly. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/125632-solved-sql-syntax-cant-find-the-error/#findComment-649535 Share on other sites More sharing options...
nadeemshafi9 Posted September 24, 2008 Share Posted September 24, 2008 $pid has nothing in it, its meant to be a feild name isnt it looks more like and id, ok cool u sorted it Quote Link to comment https://forums.phpfreaks.com/topic/125632-solved-sql-syntax-cant-find-the-error/#findComment-649545 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.