PHP mysqli_sqlstate() Function

The mysqli_sqlstate() function returns the SQLSTATE error code for the last error. The error code consists of five characters. "00000" indicates no error. The values are specified by ANSI SQL and ODBC.

Object oriented style

string $mysqli->sqlstate;

Procedural style

string mysqli_sqlstate ( mysqli $link )

Returns a string containing the SQLSTATE error code for the last error. The error code consists of five characters. '00000' means no error. The values are specified by ANSI SQL and ODBC. For a list of possible values,

Examples -

Object oriented style

Procedural style

The above examples will output:

Error - SQLSTATE 42S01.

ParameterDescription
linkProcedural style only: A link identifier returned by mysqli_connect() or mysqli_init()

Returns a string containing the SQLSTATE error code for the last error. The error code consists of five characters. '00000' means no error.