This works fine but every so often say every 3-4 weeks the hit counter will suddenly drop from say 1548 to 53 (just an example not the literal numbers) - anyone with ideas as to why this is happening?
the error log shows:
PHP Warning: fread() [<a href=‘function.fread’>function.fread</a>]: Length parameter must be greater than 0 in /my/home/dir/www.mysite.com/count.php on line 6
But i must admit it means little to me and i’m not sure hwo to fix it.
wouldn’t say it is particularly busy but it has over a 1000 hits in around 2 months. Is there a modification to prevent this happening? Thanks for your reply!
We are wandering a little bit off-topic here, but given your admitted lack of programming skills - and clearly my ignorance of file locking plus your desire to know about visitors to your website - I honestly have to ask why you are not using Google Analytics. Its free and you get far more useful information about your visitors - and it will not be counting all the bots who are hitting your page – well it’ll filter out a lot of them anyway.
You have to use MySQL instead of using the text based database to solve this issue. If you have too many visitors, then it is more likely to have a condition in which two users execute the script at the same time. Which results in making the content of the text file back to zero.
Please store the data in mysql instead of using text based database.