fclose() problem

From: Date: Fri, 07 Jul 2000 06:15:46 +0000
Subject: fclose() problem
Groups: php.general 
Request: Send a blank email to php-general+get-5322@lists.php.net to get a copy of this message
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.

« previous php.general (#5322) next »