Re: UPDATE table problem

From: Date: Mon, 15 Oct 2001 14:23:40 +0000
Subject: Re: UPDATE table problem
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-13332@lists.php.net to get a copy of this message
$update_query =3D "update guestbook set last_access=3Dnow() where = guest_id=3D'$result'"; $update_query =3D stripslashes($update_query); echo $update_query; echo "<BR><BR>"; $updated =3D mysql_query($update_query) or die(mysql_error()); if ($updated) {.............etc etc } -------------------------- When ran, it returns: update guestbook set last_access=3Dnow() where guest_id=3D'Resource = id#2' The problem is that if($updated) returns TRUE, but the last_access field = is not updated at all !!! :((( Any ideas as far as the $update_query is concerned??? ****** George, Would the mysql_affected_rows function better suit your requirements? - returns the number of rows affected by the last INSERT, UPDATE or DELETE query http://www.php.net/manual/en/function.mysql-affected-rows.php If it returns -1 there is a logic failure in the query. If it returns >=0 then that many rows were updated - provided data did actually change. NB read the manual page carefully for that 'gotcha'. Hope this helps! I have just posted a tutorial level coverage of post-processing the mysql_query function to the [PHP] list (PHP-General) (Re: [PHP] MySQL resource). If you're interested but do not subscribe, I'll email-forward you a personal copy upon request. Regards, =dn

« previous php.db (#13332) next »