PHP Tutorial - PHP mysqli_connect_error() Function






Definition

The mysqli_connect_error() function returns the error description from the last connection error.

Syntax

PHP mysqli_connect_error() Function has the following syntax.

mysqli_connect_error();

Return

A string that describes the error. NULL is returned if no error occurred.

Example

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());
}
?>