Re: PHP Update query

From: Date: Thu, 05 Nov 2009 12:24:53 +0000
Subject: Re: PHP Update query
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-46632@lists.php.net to get a copy of this message
Jason Gerfen wrote: > $query = "UPDATE clients SET > company = '$company', > contact = > '$contact', phone = '$phone', > city = '$city' WHERE > clients.reference =$client > LIMIT 1"; > $client_result=mysql_query($query); > > // now check for errors > mysql_error() & mysql_errno() > > Sudheer Satyanarayana wrote: >> On Tuesday 03 November 2009 11:29 AM, Ron Piggott wrote: >>> How do I test if an UPDATE query worked >>> >>> $query = "UPDATE clients SET >>> company = '$company', >>> contact = >>> '$contact', phone = '$phone', >>> city = '$city' WHERE >>> clients.reference >>> =$client LIMIT 1"; >>> $client_result=mysql_query($query); >>> >>> ??? >>> >>> Ron >>> >>> >> From the manual page: >> >> "For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, >> *mysql_query()* returns *TRUE* on success or *FALSE* on error. " >> >> If $client_result == true you know the query was successful. >> >> > > Those solutions will tell you if the query had no syntax errors. It won't tell you if any rows were updated. As was mentioned by others, the solution is mysql_affected_rows() which will "Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query" Cheers -- David Robley Echo Trek: To boldly go off-topic where &#*@^$ NO CARRIER Today is Prickle-Prickle, the 17th day of The Aftermath in the YOLD 3175.

« previous php.db (#46632) next »