Page 1 of 1

Accessing multiple databases

Posted: Sun Jan 18, 2004 10:50 pm
by mikusan
I am making a game, the code is all mine, but it's written on an already present PHP engine namely, geeklog. Now, I take advantage of the preexisting code, but i ran into a problem. The include file i include also includes a default connection to the database.

The game i am making does not work on that database, so i made my own little:

Code: Select all

mysql_connect('localhost', '', '')
       or die("Could not connect to Database");
	
    mysql_select_db('otherdatabase') or die("Could not select database");
Nothing fancy. But i am confused as to what i have just done,
Does my little connection override the already existinig one? Will they be in conflict with each other?

I have been getting some unexpected results, but i am hoping this is due to some code flaw and not a database fight.

Thank you in advance,

Posted: Sun Jan 18, 2004 11:00 pm
by markl999
You can connect to multiple databases, e.g.
$db1 = mysql_connect(...);
$db2 = mysql_connect(...);
Just be sure to use the optional [, resource link_identifier] in the mysql_ functions to refer to the database connection you want to work with.