Forum Moderators: coopster
The code I generally use for connecting to a database looks like this.
$db = mysql_connect('localhost', 'user, 'password') or die("Couldn't connect to the database.");
mysql_select_db('database') or die("Couldn't select the database");
How would I change this to connect to a database on a differnt server? would i Just replace the 'localhost' with the site url? Are there any catches that I need to know about to make this work?
Thanks in advance.
-Chris
Kinda.. you'd replace it with the hostname or IP address of the server you are accessing.
<Are there any catches that I need to know about to make this work?>
Yes.. you need to make sure that you've configured the user you're connecting with to be able to connect to the server remotely instead of from localhost. You can check the MySQL documentation for details on how to configure the user in this way.