Bug #14906: The function mysql_select_db set the db for other link ids than specified.
| From: | jparneodo at yahoo dot fr | Date: | Mon, 07 Jan 2002 12:27:55 +0000 |
| Subject: | Bug #14906: The function mysql_select_db set the db for other link ids than specified. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-76168@lists.php.net to get a copy of this message | ||
From: jparneodo@yahoo.fr
Operating system: RedHat 7.1
PHP version: 4.1.0
PHP Bug Type: MySQL related
Bug description: The function mysql_select_db set the db for other link ids than specified.
PHP 4.1.0 and MySQL 3.23.41-log
The function mysql_select_db set the db for other link
identifiers than specified.
Doc:
bool mysql_select_db (string database_name, resource [link_identifier])
mysql_select_db() sets the current active database on the server that's
associated with the specified link identifier. If no link identifier is
specified, the last opened link is assumed. If no link is open, the
function will try to establish a link as if mysql_connect() was called
without arguments, and use it.
The table my_table is in db1 but the active database
seems to be test on link #8.
Here the result:
mysql_pconnect() id1=Resource id #8
mysql_select_db(db1,Resource id #8)
mysql_pconnect() id2=Resource id #9
mysql_select_db(test,Resource id #9)
mysql_query(select * from my_table,Resource id #8)
failed: Table 'test.my_table' doesn't exist
Here the source:
$id1=mysql_pconnect($host,$user,$pass);
if($id1==false){
die("<br>mysql_pconnect() failed: ".mysql_error());
}
echo "<br>mysql_pconnect() id1=$id1";
$b=mysql_select_db($db1,$id1);
if($b==false){
die("<br>mysql_select_db($db1,$id1)
failed:".mysql_error());
}
echo "<br>mysql_select_db($db1,$id1)";
$id2=mysql_pconnect($host,$user,$pass);
if($id2==false){
echo "<br>mysql_pconnect() failed: ".mysql_error();
}
echo "<br>mysql_pconnect() id2=$id2";
$b=mysql_select_db($db2,$id2);
if($b==false){
die("<br>mysql_select_db($db2,$id2)
failed:".mysql_error());
}
echo "<br>mysql_select_db($db2,$id2)";
$sql='select * from my_table';
$result=mysql_query($sql,$id1);
if($result==false){
die("<br>mysql_query($sql,$id1)
failed:".mysql_error());
}
--
Edit bug report at: http://bugs.php.net/?id=14906&edit=1