Troy297
06-02-2007, 02:59 AM
Hey,
I have made a dj panel to put on peoples website and it uses the fopen to check the panels version against the lastest one in a text file on my website. The problem is when my site is down the fopen just keeps looping and pretty much destroys the homepage where the "you need to upgrade" message would appear because it can't reach my servers.... how would I stop the PHP loop and display an error if the server/file can't be found?
Heres my syntax:
$filename = "http://www.quickscriptz.ca/radiodjpanel_update.txt";
$handle = fopen("$filename", "r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
$_divide = explode("&", $contents);
$_array = 0;
echo "<center>";
while($_divide[$_array] != '')
{
$result = mysql_query("SELECT panel_version FROM rp_data") or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
$currentversion = $row['panel_version'];
list($_version, $_html, $_message) = explode("~", $_divide[$_array]);
if($_version != $currentversion|$_SESSION['rank'] == "Administrator"){
echo "<blockquote class='exclamation'>A newer version of the Radio DJ Panel is available for download. Click <a href='admin/update.php'>here</a> to update your panel.</blockquote>";
}
$_array++;
echo "</center>";
Thanks in advance! +Rep for solutions! :thumbsup:
I have made a dj panel to put on peoples website and it uses the fopen to check the panels version against the lastest one in a text file on my website. The problem is when my site is down the fopen just keeps looping and pretty much destroys the homepage where the "you need to upgrade" message would appear because it can't reach my servers.... how would I stop the PHP loop and display an error if the server/file can't be found?
Heres my syntax:
$filename = "http://www.quickscriptz.ca/radiodjpanel_update.txt";
$handle = fopen("$filename", "r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
$_divide = explode("&", $contents);
$_array = 0;
echo "<center>";
while($_divide[$_array] != '')
{
$result = mysql_query("SELECT panel_version FROM rp_data") or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
$currentversion = $row['panel_version'];
list($_version, $_html, $_message) = explode("~", $_divide[$_array]);
if($_version != $currentversion|$_SESSION['rank'] == "Administrator"){
echo "<blockquote class='exclamation'>A newer version of the Radio DJ Panel is available for download. Click <a href='admin/update.php'>here</a> to update your panel.</blockquote>";
}
$_array++;
echo "</center>";
Thanks in advance! +Rep for solutions! :thumbsup: