Jump to content

Remote DB connection


stualk

Recommended Posts

Is it possible to host a site on one server and connect to a db on another? I always thought it was possible but i'm struggling at the moment!

Here's the code i'm using:

[code]
<?
$user="username_here";
$pass="password_here";
$host="host_ip_address_here";
$dbname="db_name_here";

$connection = mysql_connect($host, $user, $pass);
if (!$connection){
  echo "Could not connect to database: " .mysql_error();
}
$founddb = mysql_select_db($dbname, $connection);
if (!$founddb){
  echo "Could not find DB: " .mysql_error();
}
?>
[/code]

Beside the 'host' field I've tried using the server IP address, the web address, the mysql admin address, the domain on it's own...Nothing has worked!
Link to comment
https://forums.phpfreaks.com/topic/34745-remote-db-connection/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.