The mysqli_connect_errno() function returns the error code from the last connection error.
PHP mysqli_connect_errno() Function has the following syntax.
mysqli_connect_errno();
An error code value for the last call to mysqli_connect(), if it failed. zero means no error occurred.
Get the error code from the last connection error
<?php
$con=mysqli_connect("localhost","wrong_user","my_wrongPassword","my_WrongDatabase");
// Check connection
if (!$con){
die("Connection error: " . mysqli_connect_errno());
}
?>