ohdang888 Posted March 4, 2008 Share Posted March 4, 2008 From the code below, i am getting this 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 ''1' = 0 WHERE `id`='5'' at line 1 whats wrong with my query? BTW, in this case, $field = 1 if($action = 'deny'){ mysql_connect("localhost", "root", "pancakes1") or die(mysql_error()); mysql_select_db("members") or die(mysql_error()); mysql_query("UPDATE `friend_requests` SET '{$field}' = 0 WHERE `id`='{$id}' ") or die(mysql_error()); Echo 'Friend Request Successfully Denied'; } Quote Link to comment https://forums.phpfreaks.com/topic/94189-error-in-my-query/ Share on other sites More sharing options...
jandrews3 Posted March 4, 2008 Share Posted March 4, 2008 Try: "Update friend_requests SET field=0 WHERE id='$id'"; Quote Link to comment https://forums.phpfreaks.com/topic/94189-error-in-my-query/#findComment-482528 Share on other sites More sharing options...
ohdang888 Posted March 4, 2008 Author Share Posted March 4, 2008 that won't work. I have several columns, named, 1, 2, 3 etc..... So i need the column name to be stored in a variable. Quote Link to comment https://forums.phpfreaks.com/topic/94189-error-in-my-query/#findComment-483241 Share on other sites More sharing options...
jandrews3 Posted March 12, 2008 Share Posted March 12, 2008 Try: "Update friend_requests SET '$field' = '$value' WHERE id='$id'"; Quote Link to comment https://forums.phpfreaks.com/topic/94189-error-in-my-query/#findComment-490221 Share on other sites More sharing options...
maxudaskin Posted March 12, 2008 Share Posted March 12, 2008 or just put the all in with AND between them Quote Link to comment https://forums.phpfreaks.com/topic/94189-error-in-my-query/#findComment-490271 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.