mysqli::$errno
(mysqli_errno) Returns the error code of the most recent function call
errno
/ mysqli_errno()
function returns the last error code (if any) of the last function call.
Returns the last error code 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 ( "Errorcode: " . $mysqli -> errno ) ; } $mysqli -> close ( ) ; ?>
Returns the last error code 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 ( "Errorcode: " . mysqli_errno ( $con ) ) ; } mysqli_close ( $con ) ; ?>