mysqli::$error
(mysqli_error) Returns the previous error string description
error
/ mysqli_error()
function returns the last error description (if any) of the last function call.
Returns the last error description of the last function call (if any):
<?php $mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ; if ( $mysqli -> connect_errno ) { echo "Failed to connect to MySQL: " . $mysqli -> connect_error ; exit ( ) ; } // Execute the query and check for errors if ( ! $mysqli -> query ( "INSERT INTO Persons (FirstName) VALUES ('Glenn')" ) ) { echo ( "Error description: " . $mysqli -> error ) ; } $mysqli -> close ( ) ; ?>
Returns the last error description of the last function call (if any):
<?php $con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ; if ( mysqli_connect_errno ( ) ) { echo "Failed to connect to MySQL: " . mysqli_connect_error ( ) ; exit ( ) ; } // Execute the query and check for errors if ( ! mysqli_query ( $con , "INSERT INTO Persons (FirstName) VALUES ('Glenn')" ) ) { echo ( "Error description: " . mysqli_error ( $con ) ) ; } mysqli_close ( $con ) ; ?>