Jump to content

Syntax Error


jakeruston

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/116173-syntax-error/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/116173-syntax-error/#findComment-597405
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.