Jump to content

connect to mysql on one server from another


slancasterfreak

Recommended Posts

I have connected to my MySQL database before using:

$db_connect=mysql_connect("localhost","dogbones","jdhkjn7676") or die ("Could not connect to database");
mysql_select_db("$db") or die ("Could not select database");


before, but what if I want to connect to it from another website, would I do something like:

$db_connect=mysql_connect("http://www.thisother.com","dogbones","jdhkjn7676") or die ("Could not connect to database");
mysql_select_db("$db") or die ("Could not select database");


Would that work, or do I need some "port" or "socket" thing or numerical IP address in there or what?

Thanks in advance!!!

Sally
www.family-gathering.org
Link to comment
Share on other sites

To connect to a remote server you will need either the IP address of the server of the domain name of the site the server is installed on aswell as the a port number which is 3306 by defualt. SO i order to connect to a remote mysql server you'll do this:
[code]mysql_connect("example.com:3306", "userName", "passWord")[/code]
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.