|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5708 fopen claims file does not exist after first couple uses.
Submitted: 2000-07-20 21:46 UTC Modified: 2001-09-09 14:16 UTC
From: mark at peak-comm dot com Assigned:
Status: Not a bug Package: Misbehaving function
PHP Version: 3.0.16 OS: Linux
Private report: No CVE-ID: None
 [2000-07-20 21:46 UTC] mark at peak-comm dot com
I'm opening up a series of files with fopen, and reading them into an array using fgets.  After reading the first couple files in succesfully, fopen falsly reports that further files do not exist.

Each of the failures echoes the $filename, if I take that URL and pull it up in a web browser, it retrieves the file.

This is all in a loop that generates the filename variables.

for (....... {

  $filename = "" . $year . "/" . $months $month] . "/" . $day . "/" . "$query[$ws]" . ".txt";
  $fd = @fopen($filename,"r"); 
  if (!$fd) { 
    print "Unable to open file: $filename" . "<br>";
  while (!feof($fd)) {
    $data[] = fgets($fd, 4096);
  fclose ($fd);

....... } 

So what I end up with is proper information for the first file or two, the rest of the files fail regaurdless of whether they exist or not.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-09 09:34 UTC]
I highly doubt this is truly a PHP bug, if you can find a
test case that can always be reproduced, please open a new
bug report.
 [2001-09-09 14:16 UTC] mark at peak-comm dot com
After upgrading to php 4, this problem disapeared.  But it is still reproducable on any of my servers still running 3.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Oct 25 14:01:23 2020 UTC