connecting to MYSQL remote database
I have 3 different hosts. One host contains a mysql database and the other 2 hosts (are supposed to anyway) connect to the database remotely. However, only one of them does. The other one does not. It just spits out an error at me. Here is the code I am using to connect. It is identical on both machines which leads me to believe that I have to do something to the host machine, (or maybe something iptables related? i'm not sure). Does anyone know how to fix this? TIA.
<?
// hostname or ip of server
$servername='**********';
// username and password to log onto db server
$dbusername='*********';
$dbpassword='********';
// name of database
$dbname='*********';
////////////// Do not edit below/////////
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
?>
|