Page 1 of 1

php Update command

Posted: Sat May 24, 2008 6:16 am
by nitsmooth
I m trying to update the database but my update command is not working ....plz help??

command:
-------------------------------------------------------------------------------------
mysql_query("UPDATE user SET
'username' = '$_POST[student_name]' and 'Address' = '$_POST[address]'
WHERE 'id' = '$_GET[stud_id]' ");

Re: php Update command

Posted: Sat May 24, 2008 6:18 am
by VladSun
You are missing the string concatenation operator - "."

Re: php Update command

Posted: Sat May 24, 2008 6:21 am
by nitsmooth
could u plz tell whr exactly to put . operator

Re: php Update command

Posted: Sat May 24, 2008 6:27 am
by VladSun
Ops, sorry, my mistake.

Ok - you have a SQL error
the valid Update syntax is:
[sql] UPDATE table_nameSET field_name_1 = value_1, field_name_2 = value_2, field_name_3 = value_3 ....WHERE field_name = value [/sql]

i.e. use coma instead of "AND" in your query.