Does anyone know what is wrong with this coding? I first thought that the mysql database was down, but then I realized that my other pages were working that also relied on the database. This is the error I get:
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /web/sites/291/vageeka/www.stardefenders.f2s.com/recordshall.php on line 23
Warning: MySQL: A link to the server could not be established in /web/sites/291/vageeka/www.stardefenders.f2s.com/recordshall.php on line 23
Line 23 is where the mysql querry is, please help!
<?php
include("functions.php");
$dbhost ="myhost";
$dbuname="myname";
$dbpass ="mypassword";
$dbname ="mydbname";
mysql_pconnect($dbhost, $dbuname, $dbpass) or die("Unable to connect to database");
@mysql_select_db("$dbname") or die ("Unable to select database");
pageHeader();
tableHeader("Records Hall");
/////////////////////////////////////////////////////////////////////////////////////////
// Top 10 Oldest //
$showoldest = "yes"; //turn off?
/////////////////////////////////////////////////////////////////////////////////////////
if ($showoldest == "yes") {
$result = mysql_query("SELECT username,joinTS,ID FROM Users ORDER BY joinTS ASC LIMIT 0, 10") or die (mysql_error());
// read everything into an array
while (list($username,$joinTS,$ID) = mysql_fetch_row($result)) {
$username_array[] ="$username";
$joinTS_array[] ="$joinTS";
$ID_array[] ="$ID";
}
echo "<center>\n";
echo "<b>Top 10 Oldest Members</b><br><br>\n";
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n";
for ($x=0; $x<count($username_array); $x++) {
////////////////////////////////////////////////
// Show how long member is in clan //
////////////////////////////////////////////////
$Syear = date("Y");
$Searlieryear = $Syear-1;
$Searlierdays = $Searlieryear*365;
$Snewdays = date("z");
$Stoday = $Searlierdays+$Snewdays;
$showthisdate = $Stoday-$joinTS_array[$x];
/////////////////////////////////////////////////
echo " <tr>\n";
echo " <td><a href='#'onClick=\"MyWindow1=window.open('/viewprofile.php?cmd=viewprofile&u=" . $username_array[$x] . "','MyWindow1','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=515,height=330,left=0,top=0'); return false;\">" . $username_array[$x] . "</a></td>\n";
echo " <td>(" . $showthisdate . " Days)</td>\n";
echo " </tr>\n";
}
echo "</table>\n";
echo "</center>\n";
}
////////////////////////////////////////////////////////////////////////////////////////
mysql_close();
tableFooter();
pageFooter();
?>