Connecting to a database
The Mysqli_connect () function opens a new connection to the MySQL server.
<? php $con =mysqli_connect ( " localhost " , " Span style= "COLOR: #800000" >wrong_user ", " my_password " , " my_db " ); // Check the connection If (! $con) {die ( " connection error: " Mysqli_connect_error ()); } ?
Set character encoding
// Modify the database connection character set to UTF8mysqli_set_charset ($con,"UTF8");
Execute SQL
// Execute Query mysqli_query ($con,"select * from websites");
Returns the number of rows affected
Mysqli_affected_rows (connection);
Returns the ID generated after execution
MYSQLI_INSERT_ID (connection);
Get a row from the result set as an associative array
MYSQLI_FETCH_ASSOC (result);
Releasing the result set
Mysqli_free_result (result);
Close Database Link
Mysqli_close (connection);
PHP 5 mysqli Function Summary