RE: [PHP] Best way to check if a query succeeded

From: Date: Thu, 29 Mar 2001 12:43:30 +0000
Subject: RE: [PHP] Best way to check if a query succeeded
Groups: php.db php.general 
Request: Send a blank email to php-general+get-46078@lists.php.net to get a copy of this message
What about: $sql = "SELECT something FROM table"; $result = mysql_query($sql) or die ("Query failed!"); do_something(); //the query has succeeded if we get to this line HTH Jon -----Original Message----- From: Jordan Elver [mailto:jjelver@worldsites.net] Sent: 29 March 2001 12:00 To: PHP Database Mailing List; PHP General Mailing List Subject: [PHP] Best way to check if a query succeeded Hi, i was just wondering what you guys do to check if a wquery suceeded or not? I know about mysql_num_rows() and mysql_affected_rows(), just wondered what you guys do? I normally do something like: $sql = "SELECT something FROM table"; $result = mysql_query($sql); if(@mysql_num_rows($result) > 0) { echo'Query Suceeded'; } else { echo'Query failed'; } Cheers, Jord -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net ********************************************************************** 'The information included in this Email is of a confidential nature and is intended only for the addressee. If you are not the intended addressee, any disclosure, copying or distribution by you is prohibited and may be unlawful. Disclosure to any party other than the addressee, whether inadvertent or otherwise is not intended to waive privilege or confidentiality' **********************************************************************

« previous php.general (#46078) next »