RE: [PHP] for loop not working
| From: | hadi | Date: | Sat, 14 Jun 2014 20:00:38 +0000 |
| Subject: | RE: [PHP] for loop not working | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323463@lists.php.net to get a copy of this message | ||
Does the user your script is running as (usually apache or www) have read
access to those files?
Its running on local host. As apache.
> -----Original Message-----
> From: Ashley Sheridan [mailto:ash@ashleysheridan.co.uk]
> Sent: Saturday, June 14, 2014 10:49 PM
> To: hadi; 'Tomas Volf'; 'Jasper Kips'; 'Paladin'
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] for loop not working
>
>
>
> On 14 June 2014 20:47:09 BST, hadi <almarzuki2011@hotmail.com> wrote:
> >> You're missing ; after glob function.
> >
> >Thank all for tilling me putting ; after the function.
> >
> >Im getting an there error
> >
> >PHP Warning: file_get_contents($file): failed to open stream: No such
> >file or directory in /var/www/html/phptest/search2.php on line 18
> >
> >Warning: file_get_contents($file): failed to open stream: No such file
> >or directory in /var/www/html/phptest/search2.php on line 18 PHP
> >Warning: unlink($file): No such file or directory in
> >/var/www/html/phptest/search2.php on line 22
> >
> >Warning: unlink($file): No such file or directory in
> >/var/www/html/phptest/search2.php on line 22
> >
> >But The file exists im sure about it.
> >
> >> You're missing ; after glob function.
> >>
> >>
> >>
> >> On June 14, 2014 9:19:14 PM CEST, hadi <almarzuki2011@hotmail.com>
> >> wrote:
> >> >Paladin,
> >> >
> >> >> Hi, take a look at glob function.. you cannot loop over filesystem
> >> >directly. use
> >> >> glob and loop over it's result
> >> >
> >> >It's not working it giving error check my code after modifying
> >> >
> >> >(PHP Parse error: syntax error, unexpected T_FOREACH in
> >> >/var/www/html/phptest/search2.php on line 6
> >> >
> >> >Parse error: syntax error, unexpected T_FOREACH in
> >> >/var/www/html/phptest/search2.php on line 6)
> >> >
> >> >
> >> >$files = glob('/tmp/sess*')
> >> >
> >> >foreach ($files as $file)
> >> >
> >> >{
> >> >
> >> >if (time()- filemtime($ip) > 60)
> >> >
> >> >{
> >> >
> >> >$old = 'hadi';
> >> >
> >> >$filename = '$file';
> >> >
> >> >$file1 = file_get_contents($filename);
> >> >
> >> >strpos($file1, $old);
> >> >
> >> >unlink ($filename);
> >> >
> >> >break();
> >> >
> >> >}
> >> >}
> >> >
> >> >?>
> >> >
> >> >> On , hadi wrote:
> >> >> > Hi ,
> >> >> >
> >> >> > Can someone help me to fix my code. It throwing error. I
> >couldn't
> >> >> > determine how to do the for loop.
> >> >> >
> >> >> > Here is my code
> >> >> > [..]
> >> >>
> >> >> Hi, take a look at glob function.. you cannot loop over filesystem
> >> >directly. use
> >> >> glob and loop over it's result
> >> >>
> >> >> you will want something like
> >> >>
> >> >> <?php
> >> >>
> >> >> $files = glob('/tmp/sess*')
> >> >>
> >> >> foreach ($files as $file) {
> >> >> // do something with file $file
> >> >> }
> >> >>
> >> >> Hope it'll help,
> >> >> Paladin
> >> >> --
> >> >> There are only two hard things in Computer Science:
> >> >> cache invalidation, naming things and off-by-one errors.
> >>
> >> --
> >> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
> Does the user your script is running as (usually apache or www) have read
> access to those files?
> Thanks,
> Ash
Attachment: [application/pkcs7-signature] smime.p7s
Attachment: [application/pkcs7-signature] smime.p7s