Returns the last error code 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( "Errorcode: " . mysqli_errno ( $con ));} mysqli_close ( $con ); ?>The mysqli_errno() function returns the last error code for the most recently called function.
mysqli_errno( connection ) ;
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
Return value: | Returns the error code value. Returns 0 if no error occurs. |
---|---|
PHP version: | 5+ |