Page 1 of 1

mysql_query problem ...

Posted: Wed Sep 19, 2007 12:26 am
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

Posted: Wed Sep 19, 2007 12:29 am
by kreoton
comma before WHERE ;)

re: mysql_query coma before

Posted: Wed Sep 19, 2007 12:36 am
by eeau1973
Well .. i have a coma before WHERE .. and other idea ?

thanks !

Posted: Wed Sep 19, 2007 12:39 am
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, :)

re: mysql_query coma ...

Posted: Wed Sep 19, 2007 12:49 am
by eeau1973
:D

Great ! the script is working now !

thanks a lot ! ..

:bow: