Fopen() problems

Ok well I’m new at working with php. But from what I understand php IS enabled on my website. I’m trying to figure out why I am getting an error msg when I use fopen()

Here’s the php script I’m using:

<?php $fr = fopen(realpath('/home/dennis01/news.txt'), 'r'); $data = fread($fr, filesize($fr)); fclose($fr); ?>


Now when I run the php it seems to open something but when it attempts to use fread and filesize it gives me this error:

Warning: filesize(): Stat failed for Resource id #1 (errno=2 - No such file or directory) in /home/.faysidiousblender/dennis01/ on line 13

Warning: fread(): Length parameter must be greater than 0. in /home/.faysidiousblender/dennis01/ on line 13

Any help is appreciated. I’m more than willing to learn, and I will continue to check google for the answers.


It’s not a problem with fopen()

The parameter to filesize() is supposed to be the filename, not a resource:

<?php $filename = "/home/dennis01/news.txt"; $filesize = filesize($filename); $fr = fopen(realpath($filename), 'r'); $data = fread($fr, $filesize); fclose($fr); ?> :cool: Perl / MySQL / HTML+CSS

Thanks so much, that sure explains alot lol.

I can’t wait till I’ve got this added to my list of experience.