Re: fclose() problem

From: Date: Fri, 07 Jul 2000 06:28:16 +0000
Subject: Re: fclose() problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5327@lists.php.net to get a copy of this message
hi, try this it should work <? $name="./pcnum.txt"; $file=fopen($name,"r"); $Count=fread($file,filesize($name)); fclose($file); $Count= $Count+ 1; // also used $Count += 1 $fd=fopen($name,"w"); fputs($fd,$Count); fclose($fd); ?> regards gautam Peter Lewis wrote: > Please excuse my writing to this list if it the wrong one. > Let me know and I'll redirect > > Hello all, > > I have a major problem with my PHP3 script! > > a) My count file is "pcnum.txt" - permissions 0666 rw-rw-rw- > b) It contains the value of 1855 > c) I wish to open this file, increment the count, rewrite the value. > d) Using Redhat Linux 6.0 - Apache 1.3.13 with phpversion() of 3.0.7 php_mod > e) my script is:- //line numbers are NOT in script > <? > 1 $name="pcnum.txt"; > 2 $file=fopen($name,"w"); > 3 $Count=fread($file(filesize($name)); > 4 fclose($file); > 5 $Count++; // also used $Count += 1 > 6 $fd=fopen($name,"w"); > 7 fputs($fd,$Count); > 8 fclose($fd); > ?> > The only problem is, It doesn't work :-( > > Whilst testing I commented out lines 5,6,7 & 8 and it still fell over > however, when I //line 4 > IT WORKED > I also renamed the file in lines 6,7,8 and NO GO however with line 8 out > IT WORKED ... > Something doesn't like the fclose(); > > The error I receive from my ISP via squid is > " > The requested URL could not be retrieved. > While trying to retrieve the URL [no URL] > The following error was encountered > * Zero Sized Reply .. > " > Without the proxy I just get "unexpected error". > > I spoke to my ISP who also has the same errors (accessing my site) with > the fclose() included and no errors with it out. > > He also logged into my machine and had the same trouble whilst trying to GET > via telnet!! > > My main concern is that I would like to close the file before re-opening to > write. > > Is there anyone who might make some suggestions. > > I am not a programmer and my experience with php before I started this > project was 5 lines (IT worked!!), so if any special logging needed you will > need to tell me how! > > With my kind regards, > Peter Lewis > pjlewis@goldweb.com.au > > ====== > Let not mercy and truth forsake you: bind them about your neck; write them > upon the table of your heart, so shall you find favour and good understanding > in the sight of God and man. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- If it is to be, it is up to me

« previous php.general (#5327) next »