String mysqlierror(mysqli mysql); Returns the last error message for the most recent MySQLi function call that can succeed or fail. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. That's because the string needs to be single-quoted as userpref = 'BLUE', but the bigger issue is that it is vulnerable to SQL injection.You ought to be using prepared. PHP MySQLi Introduction. The MySQLi functions allows you to access MySQL database servers. Note: The MySQLi extension is designed to work with MySQL version 4.1.13 or newer. PHP mysqliconnecterror function returns an string value representing the description of the error from the last connection call, incase of a failure.
During the attempt to connect to a MySQL server, if an occurs, the mysqli_connect_error() function returns the description of the error occurred (during the last connect call).
PHP mysqli_connect_error() function returns an string value representing the description of the error from the last connection call, incase of a failure. If the connection was successful this function returns Null.
PHP Version
This function was first introduced in PHP Version 5 and works works in all the later versions.
Example
Following example demonstrates the usage of the mysqli_connect_error() function (in procedural style) −
This will produce following result −
Example
In object oriented style the syntax of this function is $con -> connect_error. Following is the example of this function in object oriented style −
This will produce following result −
Example
Following example demonstrates the behaviour of the mysqli_connect_error() function incase of a successful connection −