RE: Create account with two databases
cannuck1964 <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.devel |
|---|---|
| Message-ID | <19acd5a85b5c8916a077436b977f9e9e@osCommerce-Forums> |
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=162962#162962
----------------------------------------------------------------
Hi there,
Two mistakes from previously...first the db connection is in the file functions/databse.....NOT html_output.php...
next the function
[quote]
function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
global $$link;
if (USE_PCONNECT == 'true') {
$$link = mysql_pconnect($server, $username, $password);
} else {
$$link = mysql_connect($server, $username, $password);
}
if ($$link) mysql_select_db($database);
return $$link;
}[/quote]
handles the connection to the db. to connect to the second db, I believe all you need to do is the following.....
[quote]// make a connection to the database... now
tep_db_connect('database_server_name', 'database_user_name', 'user_password', 'database_name') or die('Unable to connect to database server!');[/quote]
this should connect you to the second database as long as you replace the info in the call above with your second db info....
to re-connect to the first just use the following
[quote]// make a connection to the database... now
tep_db_connect() or die('Unable to connect to database server!');[/quote]
and this will reconnect you to the first....forget about the configuation unless you want to change the actual db info for the second db with defined names (which might be a very good idea especially if you change servers for either db).
cheers and good luck...