note 39095 added to function.mysql-select-db

From: Date: Fri, 16 Jan 2004 21:45:07 +0000
Subject: note 39095 added to function.mysql-select-db
Groups: php.notes 
Request: Send a blank email to php-notes+get-63703@lists.php.net to get a copy of this message
Be carefull if you are using two databases on the same server at the same time. By default mysql_connect returns the same connection ID for multiple calls with the same server parameters, which means if you do <?php $db1 = mysql_connect(...stuff...); $db2 = mysql_connect(...stuff...); mysql_select_db('db1', $db1); mysql_select_db('db2', $db2); ?> then $db1 will actually have selected the database 'db2', because the second call to mysql_connect just returned the already opened connection ID ! You have two options here, eiher you have to call mysql_select_db before each query you do, or if you're using php4.2+ there is a parameter to mysql_connect to force the creation of a new link. ---- Manual Page -- http://www.php.net/manual/en/function.mysql-select-db.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39095 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39095&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39095&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63703) next »