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 Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/ 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. Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720350 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? Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720353 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"; Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720355 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. Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720359 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. Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720360 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? Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720375 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! Link to comment https://forums.phpfreaks.com/topic/137830-php-wont-update-mysql/#findComment-720381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.