Easy Tutorial
❮ Php Is_Iterable Function Php Variables ❯

PHP mysqli_error() Function

PHP MySQLi Reference Manual

Example

Returns the last error description for the most recent function call:

<?php 
// Assuming database username: root, password: 123456, database: tutorialpro 
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 

// Perform a query, check for error
if (!mysqli_query($con, "INSERT INTO websites (name) VALUES ('tutorialpro.org')"))
{
    echo("Error description: " . mysqli_error($con));
}

mysqli_close($con);
?>

Definition and Usage

The mysqli_error() function returns the last error description for the most recent function call.


Syntax

Parameter Description
connection Required. Specifies the MySQL connection to use.

Technical Details

Return Value: Returns a string with the error description. Returns "" if no error occurred.
PHP Version: 5+
--- ---
❮ Php Is_Iterable Function Php Variables ❯