reestablishing the database connection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

reestablishing the database connection

Post by ryuuka »

back again

connection is made in the index.php file and each internal link in the site is opened
in a cell of that window.
now i need to make a connection to a different database while in the same site.

how do i establish a connection to the new database for this particular part of the page
while retaining the connection defined in the index.php

the connection in the index.php needs to be maintained because the link information
and the layout for the site is recorded in the first database.

i already tried closing the connection on top of the page and reopening it on the bottom
didn't work :(

connections:
new connection:

Code: Select all

$objConn = new COM("adodb.connection");
$objConn->Open("dsn=@@@_Inventory;server=sr0005.@@@.net;database=ePO_SR0005;Trusted_Connection=yes");
essential connection:

Code: Select all

$db = new COM("ADODB.Connection") or die("Kan ADO niet starten");
$db->Open("dsn=@@@_Inventory;server=sr0005.@@@.net;database=@@@_ICT;Trusted_Connection=yes");
any suggestions on how i might go about doing this
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Isn't ADODB an ODBC database?

ADOdb supports ADODB, I believe.

http://adodb.sf.net
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What error messages are you getting? This should work exactly how you have it, provided the DSN's are correct and the Open method is working properly.
ryuuka
Forum Contributor
Posts: 128
Joined: Tue Sep 05, 2006 8:18 am
Location: the netherlands

Post by ryuuka »

feyd:
Isn't ADODB an ODBC database?

ADOdb supports ADODB, I believe.
what do you mean by this exactly?

Everah

that is the problem i don't get an error.
And with a connection outside the website it shows
everything i need.

Nothing shows up, not even with this:

Code: Select all

error_reporting(E_ALL); 
ini_set('display_errors', TRUE);
that's mainly the problem[/quote]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Well, if ADODB supports ODBC requests, you could use the ODBC connector functionality that PHP has.

http://php.net/ref.uodbc .. As an alternate, you could use the ADOdb library, which I've already linked to above.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

How are you error checking? You should be error checking at least twice when connecting... once when hitting the server, once when selecting a database.
Post Reply