vicodin Posted December 20, 2008 Share Posted December 20, 2008 I am getting a MYSQL Syntax error. I cant figure out what is wrong... can anyone help? mysql_select_db("MyTable") or die(mysql_error()); mysql_query("UPDATE products SET cat = '{$cat}', subcat = '{$subcat}', proname ='{$pname}', model = '{$model}', prodes ='{$pdes}', proid ='{$pid}', keywords ='{$pkey}', specs ='{$pspec}' WHERE proid = '$pid' ") or die (mysql_error()); 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 'products WHERE proid = '10057'' at line 1 Quote Link to comment Share on other sites More sharing options...
waynew Posted December 20, 2008 Share Posted December 20, 2008 mysql_select_db("MyTable") or die(mysql_error()); mysql_query("UPDATE products SET cat = '$cat', subcat = '$subcat', proname ='$pname', model = '$model', prodes ='$pdes', proid ='$pid', keywords ='$pkey', specs ='$pspec' WHERE proid = '$pid' ") or die (mysql_error()); Try that. Quote Link to comment Share on other sites More sharing options...
waynew Posted December 20, 2008 Share Posted December 20, 2008 Could you echo $pid and tell us what is says? Quote Link to comment Share on other sites More sharing options...
Psycho Posted December 20, 2008 Share Posted December 20, 2008 Create your query as a string variable and echo to the page when there is an error. Makes debugging much easier: mysql_select_db("MyTable") or die(mysql_error()); $query = "UPDATE products SET cat = '{$cat}', subcat = '{$subcat}', proname ='{$pname}', model = '{$model}', prodes ='{$pdes}', proid ='{$pid}', keywords ='{$pkey}', specs ='{$pspec}' WHERE proid = '$pid' "; mysql_query($query) or die ("Error:<br>".mysql_error()."<br>Query:<br>$query"; Quote Link to comment Share on other sites More sharing options...
vicodin Posted December 20, 2008 Author Share Posted December 20, 2008 WayneWex it gave the same Error ... mjdamato i will do that now and let you know what happens. Quote Link to comment Share on other sites More sharing options...
waynew Posted December 20, 2008 Share Posted December 20, 2008 Also... a bit unrelated... but still... You should use or trigger_error(mysql_error()); ... instead of die. Bad practise to just kill everything. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted December 20, 2008 Share Posted December 20, 2008 I am not sure but it seems to me like $pid is getting a value that MYSQL does not like. Are you filtering with mysql_real_escape_string? Quote Link to comment Share on other sites More sharing options...
vicodin Posted December 20, 2008 Author Share Posted December 20, 2008 Ok found the issue... im just a moron and didnt think it was the other MYSQL statement that was in the script but it was... Thanks for all your help! Quote Link to comment 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.