jakeruston Posted July 23, 2008 Share Posted July 23, 2008 Hi, I'm trying to run a MySQL Query: $update = "UPDATE `user` SET `weight` = 'weight' + $weight WHERE `username` = '$user'"; mysql_query($update) or die(mysql_error()); I get 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 'WHERE `username` = ''' at line 1 Any idea of why? Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted July 23, 2008 Share Posted July 23, 2008 well first the string should be $update = "UPDATE `user` SET `weight` = weight+$weight WHERE `username` = '$user'"; Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted July 23, 2008 Share Posted July 23, 2008 try that see if it works and post back please Quote Link to comment Share on other sites More sharing options...
paul2463 Posted July 23, 2008 Share Posted July 23, 2008 it is telling you that the query cannot run because the variable $user does not exist try echo out the query instead of running it and see what I mean try $update = "UPDATE `user` SET `weight` = 'weight' + $weight WHERE `username` = '$user'"; echo $update; you will find that there is no information for $user Quote Link to comment Share on other sites More sharing options...
jakeruston Posted July 23, 2008 Author Share Posted July 23, 2008 Can't believe I messed that up guys, I spelt the variable wrong in the first place. Thanks for 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.