You are here: Multiple db access from php « PHP Programming Language « IT news, forums, messages
Multiple db access from php

Posted by David on 11/11/06 22:03

Hi All,
I'm having problems attempting to access two databases from the same php
script. Both databases are on the same server. Basically, I need to open
db1, then open db2, close db2 and then return to using db1 as the default. I
thought something along the lines of the following would work but it
doesn't:

// connect to DB1
$db1c = mysql_connect (DB1_HOST, DB1_USER, DB1_PASSWORD);
mysql_select_db (DB1_NAME, $db1c)

// use DB1

// now connect to DB2
$db2c = mysql_connect (DB2_HOST, DB2_USER, DB2_PASSWORD);
mysql_select_db (DB2_NAME, $db2c)

// use DB2

// now return to using DB1
mysql_close ($db2c);
mysql_select_db (DB1_NAME, $db1c);

// use DB1

// THE END

However, what I see is that when returning to use DB1, I get access denied
warnings suggesting that the system is using the username and password of
DB2 with DB1.

Also, one thing I have noticed is that the using echo() to render the values
of $db1c and $db2c to the screen gives the same result which seems odd to
me.

Any ideas?.

Ta in advance,
Dave

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация