PHP mysqli_sqlstate() Function
In this chapter you will learn:
- Definition for PHP mysqli_sqlstate() Function
- Syntax for PHP mysqli_sqlstate() Function
- Return for PHP mysqli_sqlstate() Function
- Example
Definition
The mysqli_sqlstate() function returns the SQLSTATE error code for the last error.
Syntax
PHP mysqli_sqlstate() Function has the following syntax.
mysqli_sqlstate(connection);
Return
The error code consists of five characters. "00000" indicates no error.
The values are specified by ANSI SQL.
Example
<?php// ja va 2 s . c o m
$con=mysqli_connect("localhost","my_user","my_password","my_db");
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="CREATE TABLE Persons (Firstname VARCHAR(30),Lastname VARCHAR(30),Age INT)";
if (!mysqli_query($con,$sql)){
echo "SQLSTATE error: ". mysqli_sqlstate($con);
}
mysqli_close($con);
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_ssl_set() Function
- Syntax for PHP mysqli_ssl_set() Function
- Parameter for PHP mysqli_ssl_set() Function
- Return for PHP mysqli_ssl_set() Function
- Example - establishes secure connections using SSL for the enabled OpenSSL support
Home » PHP Tutorial » PHP MySQLi Functions