Jump to content

Recommended Posts

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.