LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   connecting to MYSQL remote database (http://www.linuxquestions.org/questions/linux-software-2/connecting-to-mysql-remote-database-291760/)

opsraja 02-18-2005 04:30 AM

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());
}
?>

Crashed_Again 02-18-2005 06:52 AM

Let me know if this tutorial works. I haven't tried it but it looks like it would do the job.


All times are GMT -5. The time now is 10:20 AM.