Returns the last error description for the most recently called function:
<?php // Assume database username: root, password: 123456, database: CODERCTO $con = mysqli_connect ( "localhost" , "root" , "123456" , "CODERCTO" ); if ( mysqli_connect_errno ( $con )) { echo "Failed to connect to MySQL: " . mysqli_connect_error (); } // Execute query and check for errors if (! mysqli_query ( $con , "INSERT INTO websites (name) VALUES ('Coder Tutorial')" )){ echo( "Error description: " . mysqli_error ( $con ));} mysqli_close ( $con ); ?>The mysqli_error() function returns the last error description for the most recently called function.
mysqli_error( connection ) ;
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
Return value: | Returns a string with a description of the error. Returns "" if no error occurs. |
---|---|
PHP version: | 5+ |