Page 1 of 1

DB Connectivity

Posted: Sun Apr 03, 2005 9:58 pm
by texanjohn
php newbie here.

I have 2 sites hosted on the same server. For simplicity, let's just say that I have abc.com and xyz.com.

I have a script that runs on xyz.com and utilizes config.php. This script does hit a database on xyz.com. There is more than one database on xyz.com.

The db is large, and I see no reason to duplicate on abc.com. I would like to move the script from xyz.com to abc.com. However, the config.php on abc.com will obviously override the db connectivity. I tried just inserting the following code in the script on abc.com (and removed the reference to config.php):

$dbms = 'mysql';

$dbhost = 'localhost';
$dbname = 'xyz_com_-_db2';
$dbuser = 'user';
$dbpasswd = 'password';

However, that doesn't seem to work. Should it? Do I have to change $dbhost? If so, to what?

Thanks.

Posted: Sun Apr 03, 2005 10:11 pm
by neophyte
The only thing you have to worry about is whether or not abc.com is getting the variables it needs.(username password dbname, dbhost) There's no reason that I know of for duplicationg a DB on the same server. If dbhost = "localhost" before the move you don't have to change it.

Hope this helps.

Posted: Sun Apr 03, 2005 10:18 pm
by feyd
it all depends on if abc.com's "localhost" is the same as xyz.com's "localhost." .. among other things.. if they aren't the same, and you host doesn't allow "remote" access to the database server (very likely) then you are pretty stuck.

You can build a script that interrogates the xyz.com server from abc.com, or enslave the abc.com database to xyz.com's...