MySql error


I’m a bit confused…
What’s wrong with this query :

$query = "UPDATE users SET group = $user_group, category = $user_category, sub_group = $user_subgroup WHERE user_name = $user_name ";
if (mysql_query($query) or die(mysql_error()))
echo "<p>DATABASE MODIFIED!</p>";

in the browser I get this error message :

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 'group = artist, category = 112, sub_group = 11205 WHERE user_name = test_user' at line 1

… !!!

GROUP is a reserved word, rename your column

Thanks! I feel a bit stupid for I haven’t checked the reserved words…


With MySQL you can also quote column names using backticks, then it doesn’t matter if the word is reserved:

UPDATE users SET [/COLOR]group[COLOR="Red"] = $user_group, category = $user_category, sub_group = $user_subgroup WHERE user_name = $user_name ";