Connecting to multiple DB's
| From: | James Taylor | Date: | Mon, 01 Apr 2002 18:47:45 +0000 |
| Subject: | Connecting to multiple DB's | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90992@lists.php.net to get a copy of this message | ||
I host a few sites, and on usually each site will have it's own MySQL database in the background. I've decided that I want to link one site to another, and need to connect to more than one database at a time.
I've found that when I try to connect to 2 or more, even if I assign the other database to another variable
(ie .
$db1 = @mysql_connect($dbhost, $dbuser, $dbpass);
$db2 = @mysql_connect($dbhost2, $dbuser, $dbpass);
)
, the last connect called is the only one that is active.
Any work arounds to this? I've been having to do it where I connect to one when needed, then connect to the other, etc. I'm thinking there has to be a better way to do this.
Also, what is the function to kill a connection to a db? Thanks!