I don't want to talk about the difference. I can see the above instance. I mainly want to know the difference between mysql_select_db and I don't recommend using this function since PHP 4.0.6 in terms of performance. Do not use this function. Replace it with mysql_select_db () and mysql_query ().
What is the difference between mysql tutorial _ db_query and mysql_query?
Mysql_db_query
/*
Mysql_db_query Syntax: int mysql_db_query (string database, string query, int [link_identifier]);
The mysql_db_query function is used to send a query string to the backend MySQL database. If the parameter link_identifier that can be omitted does not exist, the program will automatically find the connection code after other mysql_connect () connections. If an error occurs, false is returned.
*/
$ Server = 'www. bKjia. c0m ';
If (! $ Link = mysql_connect ($ server, 'mysql _ user', 'mysql _ password ')){
Echo 'could not connect to http://www.bKjia. c0m mysql ';
Exit;
}
Else
{
$ Query = mysql_db_query ('db', $ SQL, $ link );
If ($ query)
{
While ($ row = mysql_fetch_assoc ($ query )){
Echo $ row ['foo'];
}
Mysql_free_result ($ query );
}
Else
{
Echo "DB Error, cocould not query the databasen ";
Echo 'mysql Error: '. mysql_error ();
Exit;
}
}
// Let's take a look at the mysql_query function instance.
Mysql_query
$ Cn = mysql_connect ($ server, 'root', 'root ');
Mysql_select_db ('db', $ cn); // we use mysql_db_query. Do not set it here.
$ Result = mysql_query ($ SQL );
While ($ rs = mysql_fetch_array ($ result ))
{
Echo $ row ['foo'];
}
Mysql_free_result ($ result );
/*
I don't want to talk about the difference. I can see the above instance. I mainly want to know the difference between mysql_select_db and I don't recommend using this function since PHP 4.0.6 in terms of performance. Do not use this function. Replace it with mysql_select_db () and mysql_query ().
This site original tutorials reprinted Indicate source php tutorial er/php.html "> http://www.bKjia. c0m/phper/php.html
*/
?>