A strange question about mysql_close()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I want to ask a strange question.

As we know, if we connect a mysql database in the same host twice with the
same username, we won't get two new link, but two handle to only one link.
Then, if I close one of them, whether the other one will be closed together?

I wrote two pieces of code. The first is like this
<?php
$db1 = mysql_connect($host, $username, $pwd);
$db2 = mysql_connect($host, $username, $pwd);
$sql = 'show databases';
mysql_close($db1);
$res = mysql_query($sql, $db2);
$a = mysql_fetch_row($res);
print_r($a);
?>
Then the output of the $db2 is correct. So the $db2 isn't closed together
with the $db1.

But when I add a line among the code, the result is different
<?php
$db1 = mysql_connect($host, $username, $pwd);
$db2 = mysql_connect($host, $username, $pwd);
$sql = 'show databases';
mysql_close($db1);
$db1 = true; //a new line
$res = mysql_query($sql, $db2);
$a = mysql_fetch_row($res);
print_r($a);
?>
Then the output is wrong. The PHP tell me that the link is not a valid one.
I don't know how an assignment operation for the $db1 can close the $db2.
Could someone help me.
I'll appreciate your help.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux