vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Why would a simple counter "reset"? (https://vborg.vbsupport.ru/showthread.php?t=154330)

Dorign 08-04-2007 11:10 PM

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.

nico_swd 08-04-2007 11:52 PM

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.

Dorign 08-05-2007 05:39 PM

I have yet to find a database script that is easily plugged into the vB software, though. Do you know of one?

Dorign 08-09-2007 03:41 PM

Ol college try?

ZomgStuff 08-09-2007 09:30 PM

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
  • Page Generation 0.01148 seconds
  • Memory Usage 1,714KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete