PHP: <?php // ... $res = mysql_query($sql, $db) or exit('SQL error: ' . mysql_error() . ' in ' . __FILE__ . ' on line ' . __LINE__); // ... ?>