p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Re: Counter not working


Message #1 by "HollyAnn Carbino" <hcarbino@n...> on Fri, 10 May 2002 19:51:26
Ali,

I am having similar difficulties with my counter, but I am on Windows 
2000. I changed the permissions on the individual file so all could read & 
write to it but find I have a unique problem altogether. The file is 
completely erased from its folder after two browser requests! I am 
baffled! Any suggestions or advice???

Thanks in advance!
~~HollyAnn~~

> Hi,
> It is because of your file "count.dat" permission-s you must change the
> permission of your file to everyone can change this file.
> 
> If you use LINUX you ca change your file permission with this statement
> chmod a+w count.dat
> 
> Regards,
> --Ali Amirnezhad
>   ali@b...
>   http://bamdad.org/~ali/
> 
> 
> 
> On Sun, 4 Feb 2001, Brandon Nevarez wrote:
> 
> >I SEE NOW!!! I wrote out the code exactly on page 328. It outputs 1 
every
> >time I go to the page, and it also outputs 3 warnings that say
> >
> >Warning: fopen("./count.dat","w") - Permission denied in
> >c:\inetpub\wwwroot\counter.php on line 11
> >
> >Warning: Supplied argument is not a valid File-Handle resource in
> >c:\inetpub\wwwroot\counter.php on line 12
> >
> >Warning: Supplied argument is not a valid File-Handle resource in
> >c:\inetpub\wwwroot\counter.php on line 13
> >
> >why isn't this working?
> >here is my code
> >
> >
> ><?php
> >$counter_file = "./count.dat";
> >if(!($fp = fopen($counter_file, "r"))) die ("Cannot open 
$counter_file.");
> >$counter = (int) fread($fp, 20);
> >fclose($fp);
> >
> >$counter++;
> >
> >echo "You are visitor No. $counter.";
> >
> >$fp = fopen($counter_file, "w");
> >fwrite($fp, $counter);
> >fclose($fp);
> >?>
> 
Message #2 by "Nikolai Devereaux" <yomama@u...> on Fri, 10 May 2002 11:49:29 -0700
Hi HollyAnn,

> I am having similar difficulties with my counter, but I am on Windows
> 2000. I changed the permissions on the individual file so all
> could read &
> write to it but find I have a unique problem altogether. The file is
> completely erased from its folder after two browser requests! I am
> baffled! Any suggestions or advice???


Since this is in response to an old thread, can you be a bit more specific
about your problem?  post relevant code, if possible.

nik


  Return to Index