tottijohn Posted July 19, 2007 Share Posted July 19, 2007 $dir = 'matchreports'; $dh = opendir($dir); while (($file = readdir($dh)) !== false){ $fullfile = $dir . $file; $subtotal[] = file_get_contents($fullfile); I am getting this msg "Warning: file_get_contents(matchreports010407.php) [function.file-get-contents]: failed to open stream: No such file or directory" 010407.php is one of the files i need to retrieve the contents from, including others from the folder. Pardon me cause i am relatively new to PHP, thanks. Quote Link to comment Share on other sites More sharing options...
lightningstrike Posted July 19, 2007 Share Posted July 19, 2007 Umm use a / to signify $dir as a directory $fullfile = $dir . "/" . $file; Quote Link to comment Share on other sites More sharing options...
tottijohn Posted July 19, 2007 Author Share Posted July 19, 2007 That solved the error, but now another arises; "file_get_contents(matchreports/.) [function.file-get-contents]: failed to open stream: Permission denied" & "file_get_contents(matchreports/..) [function.file-get-contents]: failed to open stream: Permission denied" I am trying to get the contents from the files, count the keywords before echoing out Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 19, 2007 Share Posted July 19, 2007 u sure u have the permission in the dir..... Quote Link to comment Share on other sites More sharing options...
tottijohn Posted July 19, 2007 Author Share Posted July 19, 2007 Care to elaborate abit more on setting permission? ??? Quote Link to comment Share on other sites More sharing options...
lightningstrike Posted July 19, 2007 Share Posted July 19, 2007 Read about chmod. You will likely need a chmod value of at least 644. Quote Link to comment Share on other sites More sharing options...
tottijohn Posted July 19, 2007 Author Share Posted July 19, 2007 Thanks, i did read up on chmod. Guess the problem is i am testing it on a windows platform using WAMP5. $dir = 'matchreports'; $dh = opendir($dir); while (($file = readdir($dh)) !== false){ $fullfile = $dir. "/" . $file; $subtotal[] = file_get_contents($fullfile); } echo "$subtotal"; I am actually getting "Array" as the result instead of the contents from all the files in the folder. Am i missing out something? Quote Link to comment Share on other sites More sharing options...
tottijohn Posted July 19, 2007 Author Share Posted July 19, 2007 I'm still stuck at this, anyone? :-\ Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 19, 2007 Share Posted July 19, 2007 $dh = "dh_dir""; $dir = 'matchreports/'; if ($handle = opendir($dh)) { while (false !== ($file = readdir($dh))) { $fullfile = $dir ."/". $file; } $subtotal[] = file_get_contents($fullfile); print_r($subtotal); Quote Link to comment Share on other sites More sharing options...
tottijohn Posted July 19, 2007 Author Share Posted July 19, 2007 Thanks, guess i am on the right track. $dir = 'matchreports'; $dh = opendir($dir); while (($file = readdir($dh)) !== false){ $fullfile = $dir ."/". $file; $subtotal[] = file_get_contents($fullfile); } print_r($subtotal); //added this for my viewing purpose only $keyword = substr_count($subtotal,'earth'); echo "$keyword"; Still, it returns 0 despite having the word earth appearing multiple times in each file. 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.