PHP mysqli_error () function
Examples
Function returns the most recent call last error description:
<? 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 ( "Error Description:" mysqli_error ($ 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 ( "Error Description:" mysqli_error ($ con). );
}
mysqli_close ($ con);
?>
Definition and Usage
mysqli_error () function returns the most recently called function last error description.
grammar
mysqli_error( connection ) ;
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
technical details
return value: | Returns a string with a description of the error. If no error is returned "." |
---|---|
PHP version: | 5+ |
PHP MySQLi Reference Manual