|
When I try to add this code into my index there was obviously an error because it just comes up with a blank page, I made the database and everthing and I tested tring to connect to the database and it works. What to do?
<?
$server = "(blocked)";
$username = "(blocked)";
$password = "(blocked)";
$database_name = "ReferingWebsites";
// establish the mysql connection
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database_name, $db) or die(mysql_error());
// update the URI count or add the refering URI to the list
if ($_SERVER["HTTP_REFERER"] != "") {
$arr = parse_url($_SERVER["HTTP_REFERER"]);
if ($arr["host"] != "www.donkery.com") {
$checkURI = mysql_query("SELECT id, NumRefers FROM ReferingWebsites WHERE URI = '". $arr["host"] ."'", $db);
if (mysql_num_rows($checkURI) > 0) {
$row = mysql_fetch_array($checkURI);
mysql_query("UPDATE ReferingWebsites SET NumRefers = ". (intval($row[1]) + 1) ." WHERE id = ". $row[0], $db);
}
else
mysql_query("INSERT INTO ReferingWebsites (URI) VALUES ('". $arr["host"] ."')", $db);
}
}
// get the top ten and loop through them to display in an ordered list
$getTopTenRef = mysql_query("SELECT URI, NumRefers FROM ReferingWebsites ORDER BY NumRefers DESC LIMIT 10", $db);
if (mysql_num_rows($getTopTenRef) > 0) {
echo "<ol>";
while ($row = mysql_fetch_array($getTopTenRef))
echo "<li><a href=\"http://". $row[0] ."\" target=\"_blank\">". $row[0] ."</a> (". $row[1] .")</li>"
echo "</ol>";
}
// close the mysql connection
mysql_close($db);
?>
|