HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP MySQLi Reference : Return the error description from the last connection error, if any
The connect_error / mysqli_connect_error() function returns the error description from the last connection error, if any.
Object oriented style:
Procedural style:
Return Value: | Returns a string that describes the error. NULL if no error occurred |
---|---|
PHP Version: | 5+ |
Return the error description from the last connection error, if any:
<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
?>
❮ PHP MySQLi Reference