Jump to content

Archived

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

Mateobus

how do you connect to a server thats not localhost?

Recommended Posts

I am trying to connect to a different database that isnt on localhost.  How do i do that?

$hostname= "www.othersite.com";
$database= "database";
$username= "username";
$password= "password";
$db = mysql_connect($hostname, $username, $password) or die(mysql_error());

is this right?

Share this post


Link to post
Share on other sites
if this is a hosting provider then you will need to check with the provider for that info. Could be something like:
mysql.PROVIDERNAME.com

however, if your trying to connect to a whole other domain altogether, you probably will not be able to since most do not allow this.

Share this post


Link to post
Share on other sites
You will have to allow external mysql connection to the database you want to connect to. The configuration can only be done with root access. If you do not have it there is no other way. Ask your system adminstrator. If you use shared hosting you will need to ask your hosting company. It is likely that with shared hosting you will not be able to connect for security reasons.

Share this post


Link to post
Share on other sites

×

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.