Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Rasmus Lerdorf
On Fri, 4 Jul 2003, Kyle Babich wrote: > FYI there were no newlines involved in my program. (go back to the > message and read the code) How did you create the file in the first place? Most editors will automatically add a carriage return. Even if you had your code create it, if afterwards you

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Kyle Babich
FYI there were no newlines involved in my program. (go back to the message and read the code) On Fri, 4 Jul 2003 12:06:46 -0700 (PDT), "Rasmus Lerdorf" <[EMAIL PROTECTED]> said: > On Fri, 4 Jul 2003, Robert Cummings wrote: > > Undoubtedly the above will work as we both know, the output will be >

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Rasmus Lerdorf
On Fri, 4 Jul 2003, Robert Cummings wrote: > Undoubtedly the above will work as we both know, the output will be > "123"; however, if you look at the original code in question, there is > no "\n" tailing the output written to the counter file and thus the > increment works fine (unless of course wh

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Robert Cummings
On Fri, 2003-07-04 at 13:13, Rasmus Lerdorf wrote: > On Fri, 4 Jul 2003, Robert Cummings wrote: > > > On Fri, 2003-07-04 at 12:44, Rasmus Lerdorf wrote: > > > The difference is that you are getting a string from the file and not > > > casting it to an integer. You could also have fixed it by doi

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Rasmus Lerdorf
On Fri, 4 Jul 2003, Robert Cummings wrote: > On Fri, 2003-07-04 at 12:44, Rasmus Lerdorf wrote: > > The difference is that you are getting a string from the file and not > > casting it to an integer. You could also have fixed it by doing: > > > > $counter = (int) fread(...); > > The cast isn't

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Robert Cummings
On Fri, 2003-07-04 at 12:44, Rasmus Lerdorf wrote: > The difference is that you are getting a string from the file and not > casting it to an integer. You could also have fixed it by doing: > > $counter = (int) fread(...); The cast isn't necessary, PHP happily transforms it for him when he app

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Rasmus Lerdorf
The difference is that you are getting a string from the file and not casting it to an integer. You could also have fixed it by doing: $counter = (int) fread(...); Note however that you have a nasty race condition in your script. If you get concurrent hits they will all read the same counter

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Kyle Babich
No, because if i did that the counter would increment no matter what the IP address is. The way I have it the counter will only increment if it is a new ip address to the site. I just fixed it by switching $current++; to $current += 1; Apparently there is some small difference between the two.

Re: [PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Tom Rogers
Hi, Saturday, July 5, 2003, 12:33:25 AM, you wrote: KB> Why does this not work? It is just a simple hit counter (hence the KB> snarls, hissing, and growling). It logs the ips address but does not KB> increment $current or log it. I do have counter.txt and ips.txt chmod'd KB> to 777. Ips.txt st

[PHP] Snarl, hiss, growl (frustration)

2003-07-04 Thread Kyle Babich
Why does this not work? It is just a simple hit counter (hence the snarls, hissing, and growling). It logs the ips address but does not increment $current or log it. I do have counter.txt and ips.txt chmod'd to 777. Ips.txt starts blank and counter.txt starts with just a 0 in it. -- Kyle --