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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.