Jump to content

Why can't I do this!?


Diablosblizz

Recommended Posts

Okay so I'm making a script that requires two different databases to be queried / inserted into. Both are started in the same file: config.php. Here's the connections:

 

$billing_connection = mysql_connect("localhost", "root", "12345");
$billing_select = mysql_select_db("atb_billing", $billing_connection);

$mybb_connection = mysql_connect("localhost", "root2", "12345");
$mybb_select = mysql_select_db("blah", $mybb_connection);

 

That works fine, no errors. The issue comes when I attempt to query one of the databases within the config.php file, as seen here:

 

$select = mysql_query("SELECT * FROM `waiting_accounts` WHERE `adminver` = '0'", $billing_connection) or die(mysql_error());

 

It comes back throwing this error:

 

Notice: Undefined variable: billing_connection in /var/www/html/functions.php  on line 7

 

I have no idea why this doesn't work in the same file, although if I were to include the "config.php" and do the same thing it works perfectly fine with both databases. I've also tried to have a "functions.php" file that does all the MySQL functions that would be required in config.php, but alas I still get that error. The config.php file is include as I can get variables from it with no problem.

 

Also, upon further investigation I've noticed that if I ignore the $billing_connection resource link then it defaults to the $mybb_connection database. I figure this is because of it being created last of the two.

 

Please help me here, I have no idea why it doesn't like being called in the same page. Thanks.

Link to comment
https://forums.phpfreaks.com/topic/202601-why-cant-i-do-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.