English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I connect to a remote mysql database using php? Lets say the script is on site 123.com and the mysql database is on site abc.com

2007-09-14 13:18:20 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

$dbServer = "mysqldomain.com:port";
$dbUser = "username";
$dbPass = "password";
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");

You don't need http://, seemingly. You just specify the url (or uri).
the :port bit is optional, but if you use it, replace port with the actual port number.

If you're having trouble connecting, check that the server you are trying to connect to allows remote connections.

2007-09-14 13:39:27 · answer #1 · answered by Anonymous · 0 0

Its mostly being able to allow the remote connection.
You need to make changes to "my.cnf" and grant privledges to the users you want to allow.
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

If you have a dedicated server or IP based web account this is easy. If you are on a shared hosted server.. Your provider may not allow this as a matter of safety.

2007-09-14 20:35:47 · answer #2 · answered by Tracy L 7 · 0 0

fedest.com, questions and answers