Internal use of Mysql Connections
| From: | Bob Silva | Date: | Thu, 20 Sep 2001 15:48:46 +0000 |
| Subject: | Internal use of Mysql Connections | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-68004@lists.php.net to get a copy of this message | ||
Just curious why mysql wouldnt restore the last known internal connection id. In the code below, I
open a connection (without storing the connection id), use it, then open,use,close a different
connection, this time using a connection id, but when I close it, the original internal connection
id is history, the last query fails. It would make sense to me that php would restore the last known
connection handle (if there is one) after I call mysql_close();
I know I could call mysql_connect again after the mysql_close call and that would restore it.
Any ideas? Thanks, Bob
mysql_connect("hostname", "user", "pass");
$res = mysql_db_query("mlm","select count(*) from mlm_clients");
echo mysql_num_rows($res)."<br>";
$conn = mysql_connect("hostname", "user", "pass");
$res = mysql_db_query("rollcall","select count(*) from rollcall_students");
echo mysql_num_rows($res)."<br>";
mysql_close($conn);
FAILS --> $res = mysql_db_query("mlm","select count(*) from mlm_clients");
echo mysql_num_rows($res)."<br>";