Page 1 of 1

PHP text hit counter

Posted: Fri Sep 12, 2008 8:23 am
by jaap
Script URL:
Version of script: 1.2


Write your message below:

Using the text hit counter for a while now, works fine until now.
Suddenly when it should display 35750 it displays 6 or 12500
When I view the index file in the log dir. I see it's reset to an other
count.
When I fill in 35750 in the index.txt it's working fine again but this happened several times in a few weeks now.
Any idea ?

Jaap.

Posted: Fri Sep 12, 2008 6:59 pm
by Henrie
My idea: To many hits.

The counter works with a text database. This is not as secure as a normal database. With to many hits, it can become corrupt. In that case it is better to look for a counter that uses a real database.

Greetings,
Henrie

Posted: Fri Dec 19, 2008 8:35 pm
by Jive
Why, Henrie?!?
Can you explain a bit more, please?

Too many hits can make the counter reset??? :shock:

Posted: Fri Dec 19, 2008 11:42 pm
by Henrie
No, i can not explain, sorry.
I was just repeating what Klemen said many times before on this forum.

I can guess for reasons what i think happens, but because i can not say for a fact, i will keep it for myself.

Greetings,
Henrie

Posted: Sat Dec 20, 2008 12:01 pm
by Klemen
This sometimes happens because text files can't take as much load as for example SQL databases (for example it can get corrupted when several people are accessing the text file at the same time). Although the counter uses PHP file locking to try to prevent such things from happening I did see it happen before. I would suggest that if you get many hits you find a counter with a mySQL database rather then storing hits in a text file.

Posted: Sun Dec 21, 2008 3:42 am
by Jive
I understand, now!
Thank you!

I know nothing about mySQL database, and I don't want to lose time learning how to deal with it.