PHP mysql_errno() Function Example

PHP mysql_errno() Function Example


Posted in : PHP Posted on : February 7, 2011 at 4:43 PM Comments : [ 0 ]

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 

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics