The mysqli_connect_error() function returns the error description from the last connection error, if any.
mysqli_connect_error();