mysql_errno()
int mysql_errno([connection])This function returns the error code number for the last MySQL statement issued. The function returns 0 if there was no error. Another MySQL connection identifier may be given as an argument for the function. Here is an example:
...
$sql_stmnt = "SELECT * FROM workreqs";
$results = mysql_db_query('workrequests', $sql_stmnt)
or die (mysql_errno( ) . " " . mysql_error( ) . "\n");
$count = mysql_num_rows($results);
print "Number of Rows Found: $count \n";
...I’ve intentionally typed the name of the table incorrectly in the preceding SQL statement. It should read workreq and not workreqs. Here is the result of this script:
1146 Table 'workrequests.workreqs' doesn't exist
Notice that the error number code is given by
mysql_errno() and the message that follows it
is given by mysql_error(), which provides an
error message rather than a code.