Using mysqli_error() and mysqli_errno()
<?php
$link = mysqli_connect("hostname", "username", "password", "mydatabase");
if(!$link) {
$mysql_error = "Connection error: ".mysqli_connect_error();
die($mysql_error);
}
$result = mysqli_query($link, "SELECT * FROM foo");
if(!$result) {
$errno = mysqli_errno($link);
$error = mysqli_error($link);
die("Query Error: $error (code: $errno)");
}
?>
Related examples in the same category