note 12382 deleted from function.mysql-connect.php by sniper

From: Date: Fri, 15 Jun 2001 00:06:18 +0000
Subject: note 12382 deleted from function.mysql-connect.php by sniper
Groups: php.notes 
Request: Send a blank email to php-notes+get-14414@lists.php.net to get a copy of this message
If you need to open two or more links to one host, using identical data, the following will fail: $dbh = mysql_connect("localhost", "user", "pass"); mysql_select_db("dbname", $dbh); $dbh2 = mysql_connect("localhost", "user", "pass"); mysql_select_db("dbname2", $dbh2); PHP will happily take the existing link and assign "dbname2" to it instead of opening a new one. A very simple, yet effective workaround is simply adding the port number to one of the hostnames. $dbh2 = mysql_connect("localhost:3306","user","pass); mysql_select_db("dbname2",$dbh2); This will open a second connection to localhost, with a new Resource ID. Obviously, PHP is doing a simple string comparison on hostname, user and password, ommiting the database name. --ck

« previous php.notes (#14414) next »