Page 1 of 1

database

Posted: Fri May 17, 2002 4:58 am
by prasadharischandra
i want to link 3 database in one page but there is error occured
Table 'test.main_info' doesn't exist
HELP me
coding is
$host='localhost';
$user='root';
$pass='';
$db1='test';
$db3='test2';

$connection=mysql_connect($host,$user, $pass);

$db=mysql_select_db($db3, $connection);
$db1=mysql_select_db($db1, $connection);

$query=mysql_query("select * from testid") or die(mysql_error());

$query1=mysql_query("select * from main_info") or die(mysql_error());

Posted: Fri May 17, 2002 5:10 am
by volka
take a look at the mysql_select_db reference
the return type is a boolean. There is only one current database for one connection.
But you can do a cross-database-join if you need the data simultaneous in a query.
i.e.: SELECT db1.tbl1.f1 as fA, db2.tbl2.f2 as fB from db1.tbl1, db2.tbl2 WHERE db1.tbl1.f1 > db2.tbl2.f2

Posted: Fri May 17, 2002 10:39 am
by cwcollins
This might work:

Code: Select all

$db=mysql_select_db($db3, $connection); 
$query=mysql_query("select * from testid") or die(mysql_error()); 

$db=mysql_select_db($db1, $connection); 
$query1=mysql_query("select * from main_info") or die(mysql_error());
-c.w.collins

How about iframe?

Posted: Sun May 19, 2002 5:26 pm
by hb_mpp
would it be possible to show results of two databases on "one"
page within iframes?

Re: How about iframe?

Posted: Mon May 20, 2002 9:24 am
by cwcollins
i don't see why not... you may have to use a little javascript to do it, but i'm sure it's possible.