DB Connectivity

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
texanjohn
Forum Newbie
Posts: 5
Joined: Tue Nov 23, 2004 4:29 pm

DB Connectivity

Post 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.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
Post Reply