Re: fgets fails after fopen succeeds

From: Date: Wed, 11 May 2005 05:18:59 +0000
Subject: Re: fgets fails after fopen succeeds
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-214900@lists.php.net to get a copy of this message
On Tue, May 10, 2005 7:42 pm, Thomas Powell said: > Printing $fh printed a 1. > > My original file mode was just "r", I changed to "r+" to see if I'd > get > permissions problems. The file handle seems to be fine. fgets just doesn't > like it. > > This is an adaptation of the following code, which works fine on another > Windows 2000/Apache setup. Irony is, the original code doesn't work when > ported. I think I'm missing something in setup or permissions. Hrmph. God only knows what Windows 2K might have done with its file permissions system (or lack thereof)... What are the permissions settings on the files that work versus those that don't? Just for fun, if fgets doesn't like it, does fread like it? Remote, but distinct, possibility: Bad hardware. If the underlying hard drive is kerfraggled, then you *could* see the behaviour you're getting -- The file seems to open okay, but an attempt to actually read data conks out on a bad sector. Can you skip the fgets section ENTIRELY and just fclose() it? Once the handle is known to be corrupt (by a bad sector) then fclose() will probably die, but if you don't attempt to read a bad sector, fclose() shouldn't have much to do, and should succeed. Certainly doing a backup and running a disk check wouldn't hurt, to eliminate the hardware possibility. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#214900) next »