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?
Link to comment
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.