The mysqli_connect_error() function returns the error description from the last connection error.
PHP mysqli_connect_error() Function has the following syntax.
mysqli_connect_error();
A string that describes the error. NULL is returned if no error occurred.
Get the error description from the last connection error
<?php
$con=mysqli_connect("localhost","wrong_user","my_password","my_db");
if (!$con){
die("Connection error: " . mysqli_connect_error());
}
?>