rickm Posted May 26, 2007 Share Posted May 26, 2007 Hi, I'm using ADODB for a PHP project and am having problems with multiple (MySQL) databases. I've looked through all the docs and am stumped. I know how to use PHP and MySQL and I still haven't got a clue why this isn't working. I've got my two connections: $MAINDB = NewADOConnection('mysql'); $MAINDB->Connect($server, $user, $pwd, $db); $SHAREDDB = NewADOConnection('mysql'); $SHAREDDB->Connect($server, $user, $pwd, $db2); The variables are set just above the connection...the databases are using the same username/password/server. Now, I've got a query below this which is getting data from a table in the first database (MAINDB) however its not working. When I turn debugging on I get a message saying "table shared.table1 does not exist"...even though I've got the query set to use the "$MAINDB" connection. Query: $result = $MAINDB->execute("select * from table1 where value = ".$str.""); Error Given (with debugging turned on): -------------------------------------------------------------------------- (mysql): select * from table1 where value = VALUE -------------------------------------------------------------------------- 1146: Table 'shareddb.table1' doesn't exist Any ideas whats going wrong here? I've got the variables all defined correctly, I've got the query using the "$MAINDB" connection, but its still giving me errors Any helps is greatly appreciated. Heres a copy of the code with the connection: $server = "removed"; $user = "removed"; $pwd = "removed"; $db = "main"; $db2 = "shared"; $MAINDB = NewADOConnection('mysql'); $MAINDB->Connect($server, $user, $pwd, $db); $SHAREDDB = NewADOConnection('mysql'); $SHAREDDB->Connect($server, $user, $pwd, $db2); $MAINDB->debug = true; $result = $MAINDB->execute("select * from table1 where value = ".$str.""); Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/53065-adodb-multiple-database-connection-problem/ Share on other sites More sharing options...
MadTechie Posted May 26, 2007 Share Posted May 26, 2007 what happens if you comment out the lines <?php $SHAREDDB = NewADOConnection('mysql'); $SHAREDDB->Connect($server, $user, $pwd, $db2); ?> Link to comment https://forums.phpfreaks.com/topic/53065-adodb-multiple-database-connection-problem/#findComment-262148 Share on other sites More sharing options...
rickm Posted May 26, 2007 Author Share Posted May 26, 2007 Hi, when I comment it out it works for the first query, however I've got queries for that second database below so I need it connected...I still get the error if I move the $SHAREDDB connections further down too. Link to comment https://forums.phpfreaks.com/topic/53065-adodb-multiple-database-connection-problem/#findComment-262150 Share on other sites More sharing options...
MadTechie Posted May 26, 2007 Share Posted May 26, 2007 Few questions: are the databases local ? is it possible to change one of the passwords? try <?php $SHAREDDB = NewADOConnection('mysql'); $SHAREDDB->NConnect($server, $user, $pwd, $db2); ?> Link to comment https://forums.phpfreaks.com/topic/53065-adodb-multiple-database-connection-problem/#findComment-262166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.