php Update command

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nitsmooth
Forum Newbie
Posts: 13
Joined: Thu May 22, 2008 6:50 am

php Update command

Post 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]' ");
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php Update command

Post by VladSun »

You are missing the string concatenation operator - "."
There are 10 types of people in this world, those who understand binary and those who don't
nitsmooth
Forum Newbie
Posts: 13
Joined: Thu May 22, 2008 6:50 am

Re: php Update command

Post by nitsmooth »

could u plz tell whr exactly to put . operator
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php Update command

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply