Answer the question
In order to leave comments, you need to log in
How to work with two MySQl databases?
Always worked with one DB (MySQL). Now it was required to make a selection from a table in one database, and then from a table in another. What is the best way to organize it?
Now, in each file where there are requests, the code from the mysql.php file is "included" at the beginning
$hostname='localhost';
$username='root';
$password='';
$basename='base1';
mysql_connect($hostname, $username, $password) or die (mysql_error());
mysql_select_db($basename) or die (mysql_error());
mysql_query("set character_set_client ='utf8'");
mysql_query("set character_set_results ='utf8'");
mysql_query("set collation_connection ='utf8_general_ci'");
$hostname='localhost';
$username='root';
$password='';
mysql_connect($hostname, $username, $password) or die (mysql_error());
//вызов mysql_select_db в этом месте важен?
mysql_query("set character_set_client='utf8'");
mysql_query("set character_set_results='utf8'");
mysql_query("set collation_connection='utf8_general_ci'");
mysql_select_db('base1') or die (mysql_error());
//запросы к этой базе
mysql_select_db('base2') or die (mysql_error());
//запросы к этой базе
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question