Forum Moderators: coopster

Message Too Old, No Replies

How to access a MySQL database on a remote server

How to access a MySQL database on a remote server

         

Columbo

8:38 pm on May 4, 2008 (gmt 0)

10+ Year Member



Can anyone tell me if you can code a script running on one server to access a MySQL database on remote server?

I want to have a script compare the domain name that the script is running on to the domain name stored in a MySQL database on a remote server.

I am pretty sure that it can be done and if it can be, could someone show me a sample of the code that would be needed to achieve this?

I know how to get the domain name of the server that the script is running on using the $domain=$_SERVER['HTTP_HOST']; function but I need to know how to access the MySQL database on the remote server to compare it to.

Thanks

coopster

8:42 pm on May 4, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Columbo.

Yes, you can connect to a remote MySQL database. The connection host would be the IP address of the server instead of the more common connection of "localhost". The remote MySQL server would need to be setup to accept remote connections.

Columbo

1:00 am on May 5, 2008 (gmt 0)

10+ Year Member



Thank you very much for your help. I was pretty sure that it could be done but since I am just begining to learn php and MySQL I didn't know how.

Thanks