PHP mysqli_error() function is used to get last error message for the most recent MySQLi function call.
Syntax
array mysqli_error(connection);
Parameter | Description |
---|---|
connection : | Required parameter. The MySQL connection to be used |
Return Values : | A string that describes the error. An empty string if no error occurred. |
<?php $con = mysqli_errort("localhost","user","password","db"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (!mysqli_query($con, "SELECT * FROM employee")) { echo "Error Code: " . mysqli_error($con); } mysqli_close($con); ?>