RE: [PHP] UPDATE - MySQL ? having some trouble
| From: | Junior, Ricardo | Date: | Wed, 23 Jan 2002 17:06:15 +0000 |
| Subject: | RE: [PHP] UPDATE - MySQL ? having some trouble | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-81703@lists.php.net to get a copy of this message | ||
Hi !
The vars: $lastname, $firstname and $username are strings.
Running this code, this will be tha line generated by PHP:
"update table set lastname=Junior, firstname=Ricardo where
username=Nobody"
So MySQL will generate a error because Junior, Ricardo and Nobody are not
reserved words in SQL language. If you want MySQL understand them as
strings, you need to put them between single-quotes or double-quotes.
So your code should be:
$query = "update table set lastname='$lastname',
firstname='$firstname' where username='$username'";
Remember that numeric vars don't need to be between single or
double-quotes!!
Cheers,
_________________________________
Ricardo J. A. Júnior, Software Engineer Trainee
Bowne Global Solutions
Phone +55 21 2515 7713
ricardo.junior@bowneglobal.com.br
www.bowneglobal.com.br
-----Original Message-----
From: Phil Schwarzmann [mailto:pschwar@jhmi.edu]
Sent: Wednesday, January 23, 2002 12:46 PM
To: php-general@lists.php.net
Subject: [PHP] UPDATE - MySQL ? having some trouble
I can't the UPDATE command in MySQL to work properly. Here is my query....
$query = "update table set lastname=$lastname, firstname=$firstname where
username=$username";
Anything wrong with my syntax here?