Learning purpose: learn to connect to the database
PHP is simply a library, rich functions make PHP's very simple. It is recommended that Down a PHP function manual, the total use.
I will talk about connecting the MySQL database here.
1, MySQL_CONNECT
Open the MySQL server connection.
Syntax: int mysql_connect (String [Hostname], String [username], string [password]); return value: integer
This function establishes the connection to the MySQL server. All of these parameters can be omitted. When using this function but does not add any parameters, the default value of the parameter hostname is localhost, the default value of the parameter username is the owner of the PHP execution itine, the parameter password is an empty string (ie there is no password). The parameter hostname can be reached with the port number, which represents which port is connected to mySQL. Of course, when using the database, use mysql_close () to turn off the connection to save resources.
2, MySQL_SELECT_DB
Select a database.
Syntax: int mysql_select_db (string Database_name, int [link_identifier]); return value: integer
This function selects the database in the MySQL server for processing after the data query job (Query). Successfully returns true, returns false.
The simplest example is:
$ conn = mysql_connect ("127.0.0.1", "," ");
MySQL_SELECT_DB ("Shop");
Connect the MY SQL database to open the SHOP database. In practical applications should be enhanced.
Today, I said here, I will talk about the database reading tomorrow.