RE: [PHP-DB] accessing two databases within one script
| From: | Oscar Rylin | Date: | Tue, 05 Oct 2004 07:21:10 +0000 |
| Subject: | RE: [PHP-DB] accessing two databases within one script | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36603@lists.php.net to get a copy of this message | ||
Of course you can
$whatever_db_linkid = mysql_connect($connectiondetails_for_whatever_db);
if(is_resource($whatever_db_linkid)) { mysql_select_db('whatever_db',
$whatever_db_linkid); }
$someother_db_linkid = mysql_connect($connectiondetails_for_someother_db);
if(is_resource($someother_db_linkid)) { mysql_select_db('someother_db',
$someother_db_linkid); }
// work your magic..
mysql_close($whatever_db_linkid);
mysql_close($someother_db_linkid);
-----Original Message-----
From: Gary Rachel [mailto:gcrachel@hotmail.com]
Sent: den 5 oktober 2004 04:31
To: php-db@lists.php.net
Subject: [PHP-DB] accessing two databases within one script
I have a page where I need to access two different databases in mysql.
After accessing the first database I used mysql_close($connection);
and then code to access the other database. The first database access
works fine, the second gives me the following error message:
*Warning*: mysql_query(): Can't connect to local MySQL server through
socket '/tmp/mysql.sock'
I've tried not using the mysql_close statement. But that option doesn't
select the new database, it seems to stay connected to the previous one,
despite my specifying a new database to access. Can I not access two
databases within the same script?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php