Jump to content

how do you connect to a server thats not localhost?


Mateobus

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?
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.
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.

Archived

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

×
×
  • Create New...

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.