PHP mysqli_errno () function
Examples
Function returns the most recent call last error code:
<? php
// Assumes that the database username: root, password: 123456, database: w3big
$ con = mysqli_connect ( "localhost" , "root", "123456", "w3big");
if (mysqli_connect_errno ($ con))
{
echo "MySQL connection failed:" mysqli_connect_error ();.
}
// Execute the query, check for errors
if (! mysqli_query ($ con, "INSERT INTO websites (name) VALUES ( ' tutorial')"))
{
echo (. "Errorcode:" mysqli_errno ($ con));
}
mysqli_close ($ con);
?>
// Assumes that the database username: root, password: 123456, database: w3big
$ con = mysqli_connect ( "localhost" , "root", "123456", "w3big");
if (mysqli_connect_errno ($ con))
{
echo "MySQL connection failed:" mysqli_connect_error ();.
}
// Execute the query, check for errors
if (! mysqli_query ($ con, "INSERT INTO websites (name) VALUES ( ' tutorial')"))
{
echo (. "Errorcode:" mysqli_errno ($ con));
}
mysqli_close ($ con);
?>
Definition and Usage
mysqli_errno () function returns the most recently called function last error code.
grammar
mysqli_errno( connection ) ;
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
technical details
return value: | Returns an error code value. If no error occurs 0 is returned. |
---|---|
PHP version: | 5+ |
PHP MySQLi Reference Manual