You should also have an error on the fwrite. fclose should only be throwing that if $fp isn't a valid stream, which indicates that your fopen has also failed.
Use an if to determine if continuation is possible:
PHP Code:
if ($fp = fopen('data.txt', 'w')) { fwrite($fp, 2); fclose($fp); }
I don't know what the issue is, but concerning 'fread'
Quote:
If you just want to get the contents of a file into a string, use file_get_contents() as it has much better performance
Perhaps try file_get_contents() instead.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS