MYSQL errors, but fine on reload

wxdqz

New Member
Hi all,

I've entered the world of php-mysql and it seems to be not as scarry as I had imagined. One problem I've noticed on my pages. I use a genearal script to connect to the database:

$userName ="username";
$password ="password";
$hostName = "host.name";

$databaseName = "databasename";
$tableName = "mytable";



function printError($errorMesg)
{
printf("<BR> %s <BR>\n", $errorMesg);
}

// Connect to the Database
if (!($link=mysql_connect($hostName, $userName, $password))) {
printError(sprintf("error connecting to host %s, by user %s",
$hostName, $userName));
exit();
}

// Make $databaseName the active database
if (!mysql_select_db($databaseName, $link)) {
printError(sprintf("Error in selecting %s database", $databaseName));
printError(sprintf("error:%d %s", mysql_errno($link), mysql_error($link)));
exit();
}

This works fine, but occasionally (I'd say about 1/10th of the time), I get an error connecting to the database. The error is "Unknown MySQL Server Host". But on reloading these pages, the error disapears. My only idea about the error, which comes to me as I write this note, is that my host name is an abreviation (b.parsons.edu) which refers to a longer name (bubblegum.parsons.edu.

Any thoughts?

Thanks! Zach...
 
Back
Top