Hi, I have a script which gives me a error message whenever it can't connect to a remote host to get its news feed.
However if their web site goes offline for any reason thats NOT MY FAULT. The code is working fine because the feed comes perfectly if their site is up and running, it usually is 90% of the time.
So I thought it would be cool to use @ in front of the mysql_connect() to supress the error, but it doesn't work at all. Some else told me I did it wrong but I did it just the way he told me to.
Can anyone help? Here's a copy of my script:
<?
// Connect to database
$mysql_connection = @mysql_connect("localhost", "removed", "removed");
if (!$mysql_connection) die("mysql_connect() failed");
if (!mysql_select_db("mzanime_annNews", $mysql_connection))
die("mysql_select_db() failed");
// Fetch the stored news
$result = mysql_query("SELECT * FROM annNews");
if (!$result) die(mysql_error());
$annNews = mysql_fetch_array($result);
// If the news were last updated more than one hour ago, re-update them
if ($annNews['last_query'] < time() - 3600)
{
// Fetch the news from ANN
// You need to put your own username and password here
$a = file("http://animenewsnetwork.com/newsfeed/getnews.php?u=mzanime&p=q57913");
$n = addslashes(trim(implode("", $a)));
// Save the news to the database
$query = "UPDATE annNews SET last_query = UNIX_TIMESTAMP()";
if ($n)
{ $query .= ", news='$n'";
$annNews['news'] = stripslashes($n);
}
mysql_query($query);
}
// Display the news
echo $annNews['news'];
?>