* PHP connection MySQL Database
* Preparatory work
* In the XAMPP Software installation directory/php/ext directory
* Php_mysql.dll and Php_mysqli.dll files must exist
* In the XAMPP Software installation directory/php directory
* php.ini file-main configuration file for PHP
Extension=php_mysql.dll
Extension=php_mysqli.dll
* Configure MySQL database in PHP
* How PHP connects to MySQL database
* The process of style
* Establish a connection to the MySQL database
$conn = Mysqli_connect (Host,username,passwd,dbname,port);
* This method returns the connection object for the database
* Define SQL statements
$sql = "";
* Send SQL statement-MySQL database
$result = Mysqli_query ($conn, $sql);
* The method returns the result of executing the SQL statement
* (optional) parse result set object
* Result Set Object-Mysqli_result object
* Close the connection to the MySQL database
Mysqli_close ($conn)
* Object-oriented style
* Create mysqli or MySQL objects
$mysqli = new mysqli (host,username,passwd,dbname,port);
* Equivalent to establishing a connection to the MySQL database
* Define SQL statements
* Call the query () method of the Mysqli object to send SQL statements to the MySQL database
$mysqli->query ($sql);
* If the SELECT statement resolves the Mysqli_result object
* Call the Close () method of the Mysqli object to close the connection to MySQL
* Chinese garbled problem
* Execute Mysqli_query ($conn, ' SET NAMES UTF8 ');
* Execute $mysqli->query (' SET NAMES UTF8 ');
How PHP connects to MySQL database