Short answer is:
$Confirm does not exist.
Long answer is:
When ever dealing with files or resources, it is a good idea to make sure they are valid prior to using them. The code you posted fails to make sure the resource created by fopen is valid before attempting to use it.
Like Sheppy said, the @ suppresses error handling. So if an error occurs, no message is displayed and the script keeps going like nothing bad happened. You want to avoid using @ as much as possible, though in the case of fopen() I can't figure out a great ( simple ) solution that avoids it. If fopen() is only accepting files, and they are on the same server as this script, you could check for the files existence before calling fopen(), by using file_exists().
Knowing what $Confirm could possibly be is important.
Without knowing what $Confirm is or could possibly be, I think this is best:
PHP Code:
$fp = @fopen($Confirm, r); // Won't throw an error if fopen can't deal with $Confirm
if ( is_resource($fp) ) { // If fopen() couldn't deal with $Confirm,
// $fp won't be a resource and none of this code
// should be allowed to execute
$body = ''; // Good practice to create a string before adding anything to it
while(!feof($fp)) {
$body .= fgets($fp, 100);
}
fclose ($fp);
} else {
// Problem with fopen()
// $Confirm probably doesn't exist
}
Bookmarks