Greetings, I have been trying to resolve this one for a while, but keep running into the same brick wall. I don't see what I'm doing different from everyone else.
First, the error messages:
Warning: fwrite(): supplied argument is not a valid stream resource
Warning: fclose(): supplied argument is not a valid stream resource
Warning: unlink(tempHitlist.html): Permission denied
Now the badly written code causing the issue ;-]
PHP Code:
function hitlistHTML()
{
// Include the mySQL connection variables in the function
include('hitlist_config.php');
// Sets the files we'll be using
$srcURL = $installPath . 'hitlist.php';
$tempFilename = 'tempHitlist.html';
$targetFilename = 'hitlist.html';
// Begin by deleting temporary file in case it was not cleaned up for some reason
@unlink($tempFilename);
// Open connection to source file
$dynPage = fopen($srcURL, 'r');
// Check for errors
if (!$dynPage)
{
die("<P>Unable to load $srcURL. The hitlist.html file has not been updated!</P>");
}
// Read the contents of the URL into a PHP variable. Specify that up to 1MB of data can be read in.
$htmlData = fread($dynPage, 1024*1024);
// Close connection to source file
fclose($dynPage);
// Create the temporary file so we can write to it
$tempFile = fopen($tempFilename, 'w');
// Check for errors
if (!$tempFile)
{
die("<P>Unable to open temporary file ($tempFilename) for writing. The hitlist.html file has not
been updated!</P>");
}
// Write the data for the hitlist.html file into the temporary file
fwrite($tempfile, $htmldata);
// Close the temporary file
fclose($tempfile);
// Copy the temporary file over the hitlist.html file
$ok = copy($tempFilename, $targetFilename);
// Delete temporary file
unlink($tempFilename);
// If all this has wen't right, return back that everything is cool
if (!isset($ok))
{
return true;
}
}
Any clue what's causing this? For the record I threw the first error into google to see what it would bring back. I didn't get any info about the error, but I did find a ton of sites suffering from the same problem ;-]. Anyone know what I'm doing wrong?