Re: Connecting to two MySQL databases

From: Date: Fri, 30 Sep 2005 15:51:06 +0000
Subject: Re: Connecting to two MySQL databases
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-40433@lists.php.net to get a copy of this message
I had this problem a while ago, when you try to create the second connection to the database with the same login credentials, i.e username and password. If mysql / php detect there is a connection already established with those details it will return that specfic resouce and not create an new connection. The only way around this is to create a new username + password for this database and use those details to generate the second connection.
Actually, the mysql_connect() function takes an optional fourth argument indicating whether or not a new connection should be made. If omitted, then PHP will do exactly what you are describing. If set, then PHP will create a new connection, even if the same username/password/host combination is being used. Larry

« previous php.db (#40433) next »