PHP text hit counter

In case you have problems with some other PHPJunkyard script (not that there are THAT many).
Post Reply
jaap
Posts: 54
Joined: Sat May 06, 2006 1:54 pm

PHP text hit counter

Post 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.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post 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
Jive
Posts: 7
Joined: Sat May 13, 2006 2:33 pm

Post by Jive »

Why, Henrie?!?
Can you explain a bit more, please?

Too many hits can make the counter reset??? :shock:
Hello from Amazonia!
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post 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
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jive
Posts: 7
Joined: Sat May 13, 2006 2:33 pm

Post 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.
Hello from Amazonia!
Post Reply