Working on 2 MySQL databases within 1 .PHP file

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Working on 2 MySQL databases within 1 .PHP file

Post by impulse() »

Would this be achieved by using mysql_select_db("db-A") before the code that's going to use db-a and then mysql_select_db("db-B") before the code that's going to be accessing db-B ?

Regards,
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

can be achieved that way, or by declaring two different variables pointing to the database connections in the format of

Code: Select all

$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
$link2 = mysql_connect('example2.com:3307', 'mysql_user', 'mysql_password');
its all on the manual page at
http://uk2.php.net/manual/en/function.mysql-connect.php
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Cheers Mr Threepwood :)
Post Reply