![]() |
Why would a simple counter "reset"?
I set up a simple PHP counter on my forum last night, using a simple .txt file as the source of data, properly CHMODed and all of the good stuff. It was counting just fine, I tested it about an hour. I refreshed, closed browser, came back later, visited normally, etc. etc.. all was good. The count was at 1500ish when I closed for the night and went to bed.
I opened my site this morning, and the count was back at 15. I modified the data to 1999 to see if maybe it reset when it tried to get to 2000, but it counted just fine. I'm not really sure what caused it, but it always seems to happen. I've had it happen to me on several different servers and I've always used a different PHP counter each time (I don't know how to write it myself, I can only tweak PHP). Is this normal? Does anyone know why? I figured if it used a database instead of a .txt or .dat it wouldn't happen, but I've tried several different database using counters and haven't been able to get it to work from a template (even though I used the plugin system and what not). Any help would be greatly appreciated. I can't believe something as simple as a counter is giving me more grief than backing up databases and complex modifications, heh. |
That's the issue with txt files. You probably had too many people accessing it at the same time, and once the current count reading failed and returned false. Which would cause the counter to start from the beginning again. I'd suggest using a database for this, or, you could have a look at flock(). And before writing to the file, make sure the reading didn't fail and you have a valid count which you increase and save to the new file.
|
I have yet to find a database script that is easily plugged into the vB software, though. Do you know of one?
|
Ol college try?
|
clustermaps.com Similar, but a little different.
|
All times are GMT. The time now is 08:18 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|