Easy Tutorial
❮ Func Mysqli Character Set Name Func Math Rand ❯

PHP mysqli_errno() Function

PHP MySQLi Reference Manual

Example

Returns the error code for the most recent function call:

<?php
// Assuming database username: root, password: 123456, database: tutorialpro
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro");
if (mysqli_connect_errno($con)) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// Perform a query, check for error
if (!mysqli_query($con, "INSERT INTO websites (name) VALUES ('tutorialpro.org')")) {
    echo "Error code: " . mysqli_errno($con);
}

mysqli_close($con);
?>

Definition and Usage

The mysqli_errno() function returns the error code for the most recent function call.


Syntax

Parameter Description
connection Required. Specifies the MySQL connection to use.

Technical Details

Return Value: Returns the error code value. Returns 0 if no error occurred.
PHP Version: 5+
--- ---
❮ Func Mysqli Character Set Name Func Math Rand ❯