Learning Objective: Institute of connecting to the database
It is a PHP library, rich PHP function to some parts of quite simple. We down a proposal of the PHP function manual, used to the total.
I am here to say to connect MYSQL database.
1, mysql_connect
Open MySQL server connection.
Grammar: int mysql_connect (string [hostname] [: port], string [username], string [password]); return value: integer
This function with the establishment of the MySQL server connectivity. All of these parameters can be omitted. When using this function does not add any parameters, the parameters of the hostname default is localhost, the default username parameters for PHP implementation of the itinerary owner, parameters for password empty string (that is not password). The parameters hostname behind the colon and can increase the port, representatives of which use the port and MySQL connection. Of course, in using the database, as soon as possible the use of mysql_close () will connect switched off to save resources.
2, mysql_select_db
Select a database.
Grammar: int mysql_select_db (string database_name, int [link_identifier]); return value: integer
The function of choice in the MySQL database server for the following information for operations (query) treatment. Successful return true, then failed to return false.
The simplest example is:
$ conn = mysql_connect ( “127.0.0.1″, “”, “”);
mysql_select_db ( “shop”);
Link-MY SQL databases, open SHOP database. In practical application should be strengthened at a wrong judgement.
RSS feed for comments on this post · TrackBack URI
Leave a reply