ThomasJSmart
Programmer
- Sep 16, 2002
- 634
trying to get multiple DB connections working but not having much luck, i tried the logic approach but its not doing the trick.
i have got 2 databases that need to be opened simultaneously:
1. a general database
2. a language specific database
general database connection script:
language specific database connection script:
then some code to make the connection and test it:
the error im getting:
TEST1: bla
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in test.php on line 10
what i would like to see:
TEST1: bla
TEST2: bla
also note: i know i could do this using mysql_close and then reopening the database that i need for every query but im trying to open the databases at the top of the page(header.php), do all the queries in whatever database i need wherever i need them in the page then close the datbase connections at the bottom of the page (footer.php)
Any help much apreciated...
Thanks
Thomas
I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
i have got 2 databases that need to be opened simultaneously:
1. a general database
2. a language specific database
general database connection script:
Code:
<?
$gdb = mysql_connect("localhost", "user","pasw");
mysql_select_db("general",$gdb);
?>
language specific database connection script:
Code:
<?
$ldb = mysql_connect("localhost", "user","pasw");
mysql_select_db("english",$ldb);
?>
then some code to make the connection and test it:
Code:
<?
include ("englishdb.php");
include ("generaldb.php");
$genDB = mysql_query("SELECT info from sometable WHERE id='1'",$gdb);
while ($thisrow = mysql_fetch_array($genDB)) { echo "TEST1: ".$thisrow['info']."<br>";}
$lanDB = mysql_query("SELECT info from sometable WHERE id='1'",$ldb);
while ($thisrow = mysql_fetch_array($lanDB)) { echo "TEST2: ".$thisrow['info']."<br>";}
?>
the error im getting:
TEST1: bla
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in test.php on line 10
what i would like to see:
TEST1: bla
TEST2: bla
also note: i know i could do this using mysql_close and then reopening the database that i need for every query but im trying to open the databases at the top of the page(header.php), do all the queries in whatever database i need wherever i need them in the page then close the datbase connections at the bottom of the page (footer.php)
Any help much apreciated...
Thanks
Thomas
I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!