mysqli_stmt_errno
mysqli_stmt->errno
Returns the error code for the most recent statement call
Description
Procedural style :
intmysqli_stmt_errno
mysqli_stmtstmt
Object oriented style (property):
mysqli_stmt
interrno
For the statement specified by stmt, mysqli_stmt_errno
returns the error code for the most recently invoked statement function that can succeed or fail.
Client error message numbers are listed in the MySQL errmsg.h header file,
server error message numbers are listed in mysqld_error.h.
In the MySQL source distribution you can find a complete list of error messages and error numbers
in the file Docs/mysqld_error.txt.
&reftitle.returnvalues;
An error code value. Zero means no error occurred.
&reftitle.seealso;
mysqli_stmt_error&listendand;
mysqli_stmt_sqlstate.
&reftitle.examples;
Object oriented style
query("CREATE TABLE myCountry LIKE Country");
$mysqli->query("INSERT INTO myCountry SELECT * FROM Country");
$query = "SELECT Name, Code FROM myCountry ORDER BY Name";
if ($stmt = $mysqli->prepare($query)) {
/* drop table */
$mysqli->query("DROP TABLE myCountry");
/* execute query */
$stmt->execute();
printf("Error: %d.\n", $stmt->errno);
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
]]>
Procedural style
]]>
&example.outputs;