PHP | mysqli_error() Function Last Updated : 23 Apr, 2020 Comments Improve Suggest changes Like Article Like Report The mysqli_error() function is used to return the error in the most recent MySQL function call that failed. If there are multiple MySQL function calls, the error in the last statement is the one that is pointed out by the function. Syntax: mysqli_error("database_name") Parameters: This function accepts single parameter as mentioned above and described below: database_name: It is the database on which operations are being performed. It is a mandatory parameter. Program 1: php <?php $conn = mysqli_connect( "localhost", "root", "", "Persons"); // Check connection if (mysqli_connect_errno()) { echo "Database connection failed."; } // Check for error in query if (!mysqli_query($link, "SET Age=1")) { printf("Error message: %s\n", mysqli_error($conn)); } mysqli_close($conn); ?> Suppose the operation is being carried out on the table given below: The output will be: Error message: Unknown system variable 'Age' Program 2: php <?php $conn = mysqli_connect( "localhost", "root", "", "Persons"); // Check connection if (mysqli_connect_errno()) { echo "Database connection failed."; } // Check for error in query if (!mysqli_query($link, "SET Firstname='Arkadyuti'")) { printf("Error message: %s\n", mysqli_error()); } mysqli_close($conn); ?> Output: Error message: mysqli_error() expects exactly 1 parameter, 0 given This example also demonstrates that mysqli_error() needs a database as a parameter. Comment More infoAdvertise with us Next Article PHP | mysqli_error() Function A ArkadyutiBanerjee Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-MySQL Similar Reads PHP | mysqli_close() Function MySQLi Procedural procedure: To close the connection in mysql database we use php function mysqli_close() which disconnect from database. It require a parameter which is a connection returned by the mysql_connect function. Syntax: mysqli_close(conn); If the parameter is not specified in mysqli_close 2 min read PHP mysqli_connect() Function The mysqli_connect() function in PHP is a fundamental tool for establishing a connection to a MySQL database. This function is crucial for PHP applications that need to interact with MySQL databases, enabling them to execute queries, retrieve data, and perform various database operations.In this art 3 min read PHP | mysqli_fetch_array() Function The mysqli_fetch_array() function is used to fetch rows from the database and store them as an array. The array can be fetched as an associative array, as a numeric array or both. Associative arrays are the arrays where the indexes are the names of the individual columns of the table. On the other h 2 min read PHP | mysqli_ping() Function The mysqli_ping() function is used to ping a server connection. That is it is used to check if a host is reachable on an IP network or not. This function also tries to reconnect if an existing server connection is lost. To use this function, it is mandatory to first set up the connection with the My 2 min read PHP error_get_last() Function The error_get_last() function is an inbuilt PHP function in PHP which is used to get the last error that occurred. Syntax: error_get_last(): ?arrayParameter: This function does not accept any parameters. Return Value: It returns an associate array that explains the last error with keys "type", "mess 1 min read Like