1. Connect
① using MySQL's mysql_connect to connect
$conn = mysql_connect (' host ', ' User ', ' password ');
Note: If the MySQL port is set to 3307
Then mysql_connect ("localhost:3307", "User", "password")
$sql = ' Use library name ';
mysql_query ($sql, $conn);
mysql_query ("SET NAMES UTF8");
② Other Connection methods
You can also use mysqli and PDO
Process-oriented notation for mysql_connect series functions
And Mysqli is to encapsulate the function of MySQL into class, it is object-oriented notation
And PDO is a unified database interface, which blocks the database
Inconsistencies (such as Oracle, SQL Server ...)
That is, using PDO to connect, even if the database is replaced, can also be run
PDO is also an object-oriented notation
2. Database functions
Mysql_query (); Execute SQL statement
Mysql_fetch_assoc (); Get results from resources as associated data
Mysql_error (); Output MSSQL error message
@zhnoah
Source: http://www.cnblogs.com/zhnoah/
This article is owned by me and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original
The right to pursue legal liability.
MySQL Learning note--5.php operation MySQL