mysql_query problem ...

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
eeau1973
Forum Commoner
Posts: 27
Joined: Sat Aug 19, 2006 4:49 pm

mysql_query problem ...

Post by eeau1973 »

would somebody please tellme what's wrong with this code ?...

Code: Select all

mysql_query(" UPDATE datos
SET origenpais='$ud_origenpais', origenestado='$ud_origenestado', 
origenciudad='$ud_origenciudad', WHERE numguia='$ud_id'");
thanks in advance for your comments ...
:D
User avatar
kreoton
Forum Commoner
Posts: 42
Joined: Fri Mar 03, 2006 7:27 pm

Post by kreoton »

comma before WHERE ;)
eeau1973
Forum Commoner
Posts: 27
Joined: Sat Aug 19, 2006 4:49 pm

re: mysql_query coma before

Post by eeau1973 »

Well .. i have a coma before WHERE .. and other idea ?

thanks !
Hemlata
Forum Commoner
Posts: 35
Joined: Mon Sep 10, 2007 5:40 am
Location: India
Contact:

Post by Hemlata »

Hello eeau1973

With unexpected additional comma before 'where' condition in your query, it is always better to use proper quotes while using php variables for mysql query. Even if the above modifications does not solve your problem then use the mysql_error() function to display the proper error for your query. So modified the code from ..

Code: Select all

mysql_query(" UPDATE datos
SET origenpais='$ud_origenpais', origenestado='$ud_origenestado',
origenciudad='$ud_origenciudad', WHERE numguia='$ud_id'");
To...

Code: Select all

mysql_query("UPDATE `datos`
SET `origenpais`='" . $ud_origenpais . "', `origenestado`='" .$ud_origenestado . "',
`origenciudad`='" . $ud_origenciudad . "' WHERE `numguia`='" . $ud_id "'") or die(mysql_error());
Regards, :)
eeau1973
Forum Commoner
Posts: 27
Joined: Sat Aug 19, 2006 4:49 pm

re: mysql_query coma ...

Post by eeau1973 »

:D

Great ! the script is working now !

thanks a lot ! ..

:bow:
Post Reply