Can i connect two databases at a time?

Hi all,
I have two databases in my server.
I want to access the two databases data in a page…

For header portion of the page, i used database1.
For body portion of the page, i used database2.

But in the body, i didn’t get the data…

Is there any wrong to do so…

Yes you can create two PDO objects, for example. What code are you using now?

//passing variables from some other page.

mysql_connect($server,$username,$password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

but when i include header portion, the body of the page accessing from the second database is not getting…
where as without header( removing header part code), it is working…
why?

I can’t tell if you mean <head>, <header>, header(), navigational header or some sort of include. Could you paste in all of the code (removing the database details)?

see this page…
Design New Cable

Am including the 5-6 pages, in this page…
When you mouse over on the menu items, it is showing data…

but select box is not populated…
why?

PHP/MySQL will use the last available connection for the queries.
So, before the head you add your connection code:


mysql_connect($server,$username,$password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

and just before you include the body part of your page, connect again

HTH

Thank you mjpr…
After changing the code as you specified, now it is working.
I solved the problem…

Thanks again…