database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

database

Post 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());
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

Post 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
hb_mpp
Forum Newbie
Posts: 3
Joined: Tue May 14, 2002 6:44 pm
Location: Germany (near Hamburg)

How about iframe?

Post by hb_mpp »

would it be possible to show results of two databases on "one"
page within iframes?
User avatar
cwcollins
Forum Commoner
Posts: 79
Joined: Thu May 16, 2002 3:51 pm
Location: Milwaukee, WI, USA

Re: How about iframe?

Post 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.
Post Reply