views:

16

answers:

2

I am trying to update a value in my database but am recieving the following 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 ''users' ('new_user') VALUES ('1') WHERE 'id'= 5' at line 1

I am trying to UPDATE the table 'users' in the column 'new_user' where the id is equal to $userid. But it don't work. Please help.

$newuservalue = '1';

$notnewuser ="UPDATE 'users' ('new_user') VALUES ('$newuservalue') WHERE 'id'= $userid ";

 $query2 = mysql_query($notnewuser) or die(mysql_error());
+1  A: 

Well, your syntax is wrong. It should be:

UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]

So, remove the "values" part of your query and put in the "set" part.

Here's a link to the official documentation.

Hal
A: 

i have that problems some times, that's the code to insert a new row :d

It should be:

UPDATE users SET new_user='$newuservalue' WHERE id=$userid 

you also don't need to put quotes around your column names, that might give some problems as well.

krike