Web lists-archives.com

Re: [PHP] No such file... but there is!




Den 28-11-2017 kl. 16:34 skrev Aziz Saleh:
On Tue, Nov 28, 2017 at 10:22 AM, Jennifer <jennifer@xxxxxxxxxxxxxxxxxxxx>
wrote:

Hi!

         I'm having an intermittent problem with a script locating a text
file.  Here's the code section:


function is_crawler($agent) {
   global $path;
     $bots_file = $path;
     $spiders = file($bots_file, FILE_IGNORE_NEW_LINES |
FILE_SKIP_EMPTY_LINES);

   foreach ($spiders as $spider) {
     if (stristr($agent, $spider)) {
       return true;
    }
   }
}

         The error log shows these lines:

[28-Nov-2017 06:50:03] PHP Warning:  file(.../counter/bots.txt): failed to
open stream: No such file or directory in /home/.../counter/page_hit_counter.php
on line 235
[28-Nov-2017 06:50:03] PHP Warning:  Invalid argument supplied for
foreach() in /home/.../counter/page_hit_counter.php on line 238


         The bots file is there and is populated, so I'm not sure why this
happens from time to time.  It's not read by any other script, so I don't
think it's a locking issue(?).

         What could be causing this issue?

Thank you,
Jenni
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Use the absolute file location instead of the relative one.

.../  looks wrong.

it should be ../ (2 dots)

or if you want to go parent 2 times ../../




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php