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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.