PHP development in our daily work, when we get data from the database, the database connection after PHP, the next step is we have to choose the database file, it is necessary to use a function, mysql_select_db () function to select the database! Which is good marble Measuring Tool
Before selecting a database, we first have to do is connect to the database PHP, and today we are mainly talking about mysql_select_db () function!
the mysql_select_db () function has the following syntax:
1 |
|
or:
1 |
|
The following example uses the mysql_select_db () function to connect the database, the database is php_cn, specific examples code is as follows:
1 2 3 4 5 6 7 8 |
|
Operating results as follows:
Here supplement, the above code $ db_selected = mysql_select_db ( "php_cn", $ link); can alternatively use the following code:
1 |
|
mysql_query () function is a special function query command, all of the SQL statements executed by it, and returns the result set.