I am getting the warning on my pages
Warning: fclose(): supplied argument is not a valid stream resource
Using the following code
$fp = fopen('data.txt', 'w');
$write = '2';
fwrite($fp, $write);
fclose($fp);
Update code
if(isset($_REQUEST['go1']))
{
$fp = fopen('data.txt', 'w');
$write = '1';
$fp1 = fopen('file.php', 'w');
$write1 = '<br><img src="/1/online.png" style="position:absolute; z-index:-2;" />';
}
if(isset($_REQUEST['go2']))
{
$fp = fopen('data.txt', 'w');
$write = '2';
$fp1 = fopen('file.php', 'w');
$write1 = '<br><img src="/1/offline.png" style="position:absolute; z-index:-2;" />';
}
fwrite($fp, $write);
fclose($fp);
fwrite($fp1, $write1);
fclose($fp1);
$fp = fopen('data.txt', 'r');
$contents = fread($fp, filesize('data.txt'));
fclose($fp);
if($contents == '1')
include('file.php');
else if($contents == '2')
include('file.php');
else
echo 'Something else...';
getting the error on line 27 and line 29 line 27
fclose($fp);
line29
fclose($fp1);
Your problem is in the "if-else" statement (file not opened)... check your code