Google

Hit counter using php

Google

Hit counter using php

You may also like...

14 Responses

  1. mithun says:

    thanks

    VA:F [1.9.22_1171]
    Rating: 4.4/5 (9 votes cast)
  2. Jerry says:

    easy to understand, thanks

    VA:F [1.9.22_1171]
    Rating: 4.0/5 (7 votes cast)
  3. Daniel says:

    No matter which way I enter code to read a text file or write a text file, for some reason my counter.php won’t read or write to that file. I have used 4 different ways to code it and I always end up printing 1 view. I tried debugging before I update the counter and $value never gets a value to it, just empty.

    VA:F [1.9.22_1171]
    Rating: 2.5/5 (4 votes cast)
  4. admin says:

    Dear Daniel,

    First check if there is any extra charecters in your code when you tried to copy and paste the code above.

    Second have you checked the permissions of the TXT file you are trying to R/W with the php script.

    Third if none of the above worked pls paste the code here.I will try to rectify the issue.

    Thanks.

    VN:F [1.9.22_1171]
    Rating: 3.5/5 (4 votes cast)
  5. zain says:

    hi, where do i put the php code, most of my website is in html but i’m using IIS php 5.2 Fast CGI. I dont want my hits displayed on my website, any advice, Just want it for personal reasons. Just started a blog.
    please help

    VA:F [1.9.22_1171]
    Rating: 3.0/5 (3 votes cast)
    • admin says:

      Hello Zain,
      Since you are using html codes, i suppose all your files will have .html extension.So what you need to do is since your server support php you can do like this
      1)Create a PHP file named hit.php
      2)Copy and paste the entire code i have given in this post except echo $value
      3)add an iframe in your html code
      4)Call the hit.php from the iframe.If you want you can give the height and width of the IFRAME as 0%
      4)This will get your counter hidden from others.
      This will help you i believe.Do visit my website for more tricks thanks.

      VN:F [1.9.22_1171]
      Rating: 4.0/5 (4 votes cast)
  6. Its too simple.Just opening the txt file and incrementing var and closing the fileThats it.I didn’t thought that adding counter is so simple through PHP..Great! I will definitely try this.Thanks for sharing.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
  7. ngonidan says:

    If you get error like : Warning: fopen(“hitstxt”) [function.fopen]: failed to open stream: No error in C:\wamp\www\test\counter.php on line 3

    It’s because when you copied and pasted the code, the quotes are pasted as “hits.txt” instead of “hits.txt” in notepad.

    Solution, just replace all “ with ” and, ” with “.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  8. Adrian says:

    0 + 0 = 0

    so set the contents of hits.txt to 1

    or use $value = $value + 1

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  9. Counter for site says:

    Adding hit counter to your blog or site is always a good idea and using PHP script is great.Using PHP scripts over others has many benefits like PHP hits counter are open source and do not depend on browser configuration that’s why they track visitors perfectly.Thanks for sharing such an informative post.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  10. this is not a sufficient code for counter , i am a new learner of php. i want to create a simple counter in which a box in which number is count.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  11. Rakib says:

    Ok i try it

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  12. sundar says:

    Great and useful information. Thanks for sharing this useful information.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
  1. February 13, 2009

    [...] Hit counter using php | Tutorials, Scripts, Technology and … [...]

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Close
Please support the site
By clicking any of these buttons you help our site to get better