Jump to content

Connecting to two databases on same server


Recommended Posts

Can one, from php, connect to two databases in the same script.
I need to write an application to process and display data from two seperate MSSQL databases both on the same server.
If I write the two routines(scripts) seperately and run them as such they both work but when I put them together in one script the second one is failing?
Link to comment
Share on other sites

when you connect, set new_link to be true (see [url=http://ca3.php.net/manual/en/function.mssql-connect.php]http://ca3.php.net/manual/en/function.mssql-connect.php[/url]).

for example


  $q1=mssql_query("select 'whatever1'",$c1);
  $q2=mssql_query("select 'whatever2'",$c2);

Just be sure to qualify all of your selectdb and query function calls with the proper connection resource.
Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • 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.