Drezard Posted August 30, 2008 Share Posted August 30, 2008 Hello, Im trying to use an fopen command to read a .txt file but its throwing errors. The log.txt file is in the exact same directory as the script but its throwing these errors: Warning: fopen(C:\www\log.txt) [function.fopen]: failed to open stream: No such file or directory in C:\www\rainbow.php on line 3 Warning: fread(): supplied argument is not a valid stream resource in C:\www\rainbow.php on line 5 Warning: fclose(): supplied argument is not a valid stream resource in C:\www\rainbow.php on line Code: <?php $fileh = fopen("log.txt", "r+"); $contents = fread($fileh, 1024); echo $contents; fclose($fileh); ?> Please help because im sure I wrote all the correct code! Daniel Link to comment https://forums.phpfreaks.com/topic/121996-php5-file-io/ Share on other sites More sharing options...
Fadion Posted August 30, 2008 Share Posted August 30, 2008 That's strange if the file exists. Try file_get_contents() instead, it is a shorthand to those 3 functions you've used. Link to comment https://forums.phpfreaks.com/topic/121996-php5-file-io/#findComment-629707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.