Results 1 to 7 of 7
April 27th, 2005, 11:57 PM #12 databases on one page
I am trying to use two different databases on the same page (not tables databases) is this possible and could anyone tell me how to do it please?
I use this on my pages "require_once("./1config.php");" for the main scripts and this is the info on the 1config.inc.php
$db_user = "xxxx"; // Database user name
$db_pass = "xxxx"; // Database password
$db_name = "xxxx_xxxx"; // Database name
$db_host = "localhost";
Now my problem is when I add this to the pages just after the <body> tag somehow the database name is carried onto the script that is suposed to use the 1config.php info. Is there any way to do this please?
thanks in advance
April 28th, 2005, 02:21 AM #2
- Join Date
- January 18th, 2005
Not sure if this will work but if you are only using /2config.php that one time and not anymore, have you tried closing the database using mysql_close()after you're done with using that database and then kick off using /1config.php later on the script? And also make sure you haven't used the mysql_pconnect but the mysql_connect function when calling your database.
I'm no expert so I could be wrong...
April 28th, 2005, 03:42 AM #3
It's possible to use more than one. Your second file needs to be something like
$db_user2 = "xxxx";
$db_pass2 = "xxxx";
and you'll need another mysql_pconnect() to use that second database's information with a different set of variables.Tim
consultant by day, affiliate by night
April 28th, 2005, 04:57 AM #4
I'd use a single database class and simply issue a "use other_database" mySQL command. If your code uses the $db_name variable upon every query, you'll need to change that variable to the new DB name. Really just depends on how the code is structured. When you get down to it, you simply need to execute the "use database" mySQL command which will change the current DB.
- ScottHatred stirs up strife, But love covers all transgressions.
April 28th, 2005, 10:30 AM #5
thanks guys I'll play with these sugestions and let you know how I get on.
July 19th, 2005, 04:08 AM #6
- Join Date
- January 17th, 2005
Let me know if this worked, this has shooted a serious of creative ideas in my mind
July 25th, 2005, 08:15 PM #7Originally Posted by Gordon
OR, you could do:
if (!exists("$count". 'config.inc.php')) break; // breaks the while loop if the config don't exist :)
include("$count" . 'config.inc.php');
$db = mysql_connect ($...); // or use pconnect..
} while (1);
By bettylou in forum Midnight Cafe'Replies: 16Last Post: October 7th, 2008, 07:32 PM
By pachecus in forum Midnight Cafe'Replies: 1Last Post: June 12th, 2006, 09:54 AM
By bcorso in forum Programming / Datafeeds / ToolsReplies: 1Last Post: August 19th, 2003, 02:30 AM
By Taurus in forum Programming / Datafeeds / ToolsReplies: 24Last Post: January 22nd, 2002, 12:58 PM