The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
((( Two Simultaneous Database Connections )))
I am trying to access two databases on the same php page - one that I created, and the other being the vBulletin database.
Code:
// On Server Development $host = 'localhost'; $user = 'user"; $pass = 'passwerd'; // Define the databases $user_database = 'forum'; $cust_database = 'custom_database'; // Establish the connections $user_con = mysql_connect($host,$user,$pass) or die(mysql_error()); $cust_con = mysql_connect($host,$user,$pass) or die(mysql_error()); // Connect to the databases mysql_select_db($user_database, $user_con); mysql_select_db($cust_database, $cust_con); // Close the connections mysql_close($user_con); mysql_close($cust_con); // Demonstrate that the connections didn't throw an exception phpinfo(); It's not working and there seems to be some mechanism preventing it from working. Why can I not have two simultaneous connections? Is there some prohibition against having two simultaneous database connections with MYSQL? If you require additional information, please let me know. Thank you, Jack |
#2
|
|||
|
|||
MySQL returns the same connection ID if you connect to two databases at once. So if you do need to connect to two databases, you need to do so before each query.
In your case, $user_con will be the same as the $cust_con connection ID. You can also avoid this by passing the 4th connect parameter to the second connection like this... Code:
$cust_con = mysql_connect($host,$user,$pass,true) or die(mysql_error()); |
#3
|
|||
|
|||
That is great; I will try it
Thank you for your time! Jack |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|