Mysql select different database after connecting to one
So I'm trying to re-select a database, I have two databases, one for VB, one for a custom CMS. They're both connected, however I only store a small amount of user data on the CMS one and need to be able to retrieve the user information from VB table.
So heres the process,
- I have a 开发者_StackOverflow社区DB object already connected, and selected the CMS database
- I load up a function to get the user data
I reselect the database via
mysql_select_db("xxxx_xxxvb", $this->mysql_con);
- When I execute the function, it returns the data from the CMS's user table, and not VB
Anyone got any ideas why?
Thank you
try to open two connections
$con1 = mysql_connect('your', 'db', 'info');
$con2 = mysql_connect('your', 'db', 'info');
mysql_select_db("xxx_xxxcms", $con1);
mysql_select_db("xxx_xxxvb", $con2);
and see if it works. Don't forgot to use queries like
mysql_query("SELECT id FROM users WHERE username = 'user'", $con2);
精彩评论