mysqli::$connect_errno
(mysqli_connect_errno) Returns the error code of the last connection call
connect_errno
/ mysqli_connect_errno()
function returns the error code for the last connection error (if any).
Returns the error code for the last connection error (if any):
<?php $mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ; // Check the connection if ( $mysqli -> connect_errno ) { echo "Failed to connect to MySQL: " . $mysqli -> connect_error ; exit ( ) ; } ?>
Returns the error code for the last connection error (if any):
<?php $con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ; // Check the connection if ( mysqli_connect_errno ( ) ) { echo "Failed to connect to MySQL: " . mysqli_connect_error ( ) ; exit ( ) ; } ?>