Connect to multiple MySQL databases on a single webpage

by Francis 2013-09-24 14:57:57

Connect to multiple MySQL databases on a single webpage
To connect two mysql database in single page and how to write query in this page, following code will be helps you.


$dbcon1 = mysql_connect($hostname, $username, $password);
$dbcon2 = mysql_connect($hostname, $username, $password, true);

mysql_select_db('database1', $dbcon1);
mysql_select_db('database2', $dbcon2);

Query for database 1
like following query to do this:

mysql_query('select * from tablename', $dbcon1);

Query for database 2
like following query to do this:

mysql_query('select * from tablename', $dbcon2);
709
like
0
dislike
0
mail
flag

You must LOGIN to add comments