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

How can i connect to a database located in another server.
(***code plz***)

2007-03-09 05:05:25 · 2 answers · asked by aryaxt 3 in Computers & Internet Programming & Design

2 answers

In mysql_connect function, you will have to provide the ip address of that system where mysql is running. But your user must be allowed to access mysql database from the server where php is running.
I mean, if ur webserver (Apache/IIS) is 192.168.0.1 and your mysql is 192.168.0.2 and ur user is "test". This test must be allowed in "user" table of database "mysql" so that this can access the database on 192.168.0.2 from 192.168.0.1.

2007-03-13 01:18:36 · answer #1 · answered by Atif Majid 3 · 0 0

// Connects to a different Server Database
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error());
?>

2007-03-09 13:15:02 · answer #2 · answered by jondawg 4 · 1 0

fedest.com, questions and answers