note 59685 added to function.mysql-close
| From: | bbodelcampo at yahoo dot co dot uk | Date: | Tue, 13 Dec 2005 13:20:18 +0000 |
| Subject: | note 59685 added to function.mysql-close | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100064@lists.php.net to get a copy of this message | ||
A little note about multiple simultaneous connections to different hosts...
I work on a site that pulls content primarily from one db but uses a db on a foreign server to
verify licensing. One might expect the following to work:
// Open the connection to the primary db
$res1 = mysql_connect($host1, $user1, $pass1);
mysql_select_db($db1);
// Open connection to the license server
$res2 = mysql_connect($host2, $user2, $pass2);
mysql_select_db($db2, $res2);
// Pull license data and close when done
mysql_query($check_sql, $res2);
...
mysql_close($res2);
// Now pull content from the primary db
// Not specifying the resource should default to the last open db
mysql_query($query);
...
Turns out this last query, since it cant find an active connection, will try to connect with
mysql_connect() with no paramaters. But if instead you do it as mysql_query($query, $res1), or
alternatively, run the mysql_connect for this host again then it works fine. Thus, it doesnt seem
to be possible to have code with an overarching "global" db connection interspersed with
temporary connections to another host/db....
----
Manual Page -- http://www.php.net/manual/en/function.mysql-close.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59685
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59685&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59685&report=yes
Search -- http://master.php.net/manage/user-notes.php