mysqli_stmt_error
mysqli_stmt->error
Returns a string description for last statement error
Description
Procedural style:
stringmysqli_stmt_error
objectstmt
Object oriented style (property):
stmt
stringerror
For the statement specified by stmt, mysql_stmt_error
returns a containing the error message for the most recently invoked statement function that
can succeed or fail.
Return values
A string that describes the error. An empty string if no error occurred.
See also
mysqli_stmt_errno,
mysqli_stmt_sqlstate
Example
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: %s.\n", $stmt->error);
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>
]]>
Procedural style
]]>
The above examples would produce the following output: