Joshua4550 Posted November 21, 2009 Share Posted November 21, 2009 I'm gonna cut it short, because this is really starting to ... me off. The following code will not work. $file = "alltime.txt"; $handle = fopen($file, 'r'); The reason for this not working? Warning: fopen(alltime.txt) [function.fopen]: failed to open stream: No such file or directory in /home/*myuser*/public_html/*mysite*.com/Sources/Statistics.inc on line 4 The file is in the same directory as the file running the code. The files permissions are set for the owner to read, write, and execute. Why is it saying it does not exist? Quote Link to comment https://forums.phpfreaks.com/topic/182411-reading-files/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 21, 2009 Share Posted November 21, 2009 The code is in a file Statistics.inc. It is likely that this has been included/required into another file that is in a different folder. The fopen() is relative to the main file, not the included/required file. Is this the case? You either need to form a correct relative path, an absolute file system path (using $_SERVER['DOCUMENT_ROOT'] concatenated with the path/file information would make this easy), or alter the current working directory (CWD) to be that of where the alltime.txt file is located. Quote Link to comment https://forums.phpfreaks.com/topic/182411-reading-files/#findComment-962567 Share on other sites More sharing options...
Joshua4550 Posted November 21, 2009 Author Share Posted November 21, 2009 Just realised that. Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/182411-reading-files/#findComment-962568 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.