JohnSmith JohnSmith - 1 year ago 122
SQL Question

How to check if a MySQL query using the legacy API was successful?

How do I check if a MySQL query is successful other than using


I'm trying to achieve...


//move file
else if(fail){
//display error

Answer Source

This is the first example in the manual page for mysql_query:

$result = mysql_query('SELECT * WHERE 1=1');
if (!$result) {
    die('Invalid query: ' . mysql_error());

If you wish to use something other than die, then I'd suggest trigger_error.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download