The mysql_errno() function is used to get the numeric value of the error message from the mysql operation.
PHP mysql_errno() Function Example:
The mysql_errno() function is used to get the numeric value of the error message from the mysql operation. This function return the numeric value of the error message from mysql operation or 0(zero) if no error occurred.
Example:
<?php $connection = mysql_connect("localhost","root","root"); if (!$connection) { die('PHP Mysql database connection could not connect : ' . mysql_error()); } else{ mysql_select_db("NOT_Selected", $connection); if (!mysql_query("SELECT * FROM user", $connection)) { echo mysql_error($connection) . "\n"; } } ?>
In this example we have used "NOT_Selected" database that is not exist in the localhost database server. Now we will execute this example and see the output on the browser.
Output:
1046
[ 0 ] Comments