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:[EMAIL PROTECTED]]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



**********************************************************************
'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'

**********************************************************************

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to