Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Where can I get a webste hits counter?

Options
  • 17-04-2007 12:02am
    #1
    Closed Accounts Posts: 164 ✭✭


    Or is there any way I can configure my own?
    Would prefer a transparent one that shows just the text rather than it being surrounded by a big box of whatever colour.


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh




  • Closed Accounts Posts: 164 ✭✭defenstration


    Cheers but any way of doing this without having to use ActiveX?


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    do u have access tp php amd mysql on your hosting?


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Say what now? Google Analytics works by having you embed a tracking Javascript in your page, ActiveX doesn't come within a screaming mile of it.


  • Closed Accounts Posts: 164 ✭✭defenstration


    Say what now? Google Analytics works by having you embed a tracking Javascript in your page, ActiveX doesn't come within a screaming mile of it.

    All I know is that when I inserted the Google Analytics tracking code into my source code, then refreshed my page, I was all of a sudden getting prompted to install ActiveX. I have no problems with that myself, but most the ppl who will be accessing my site will never have heard of the thing and will probably think they're computer is about to explode or something!


  • Advertisement
  • Closed Accounts Posts: 164 ✭✭defenstration


    Ziycon wrote:
    do u have access tp php amd mysql on your hosting?

    Not sure to be honest! What if I do?


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Not sure to be honest! What if I do?
    If you do, you can create your own basic counter:

    Basicly everytime someone goes to a page call the hitCounter function and it will add 1 to the table in the DB!
    [PHP]<?php
    function hitCounter()
    {
    mysql_query("UPDATE hitCounter SET count=(count + 1) WHERE count_id=1");
    }
    ?>[/PHP]
    CREATE TABLE `hitCounter` 
    (
      `count_id` int(3) NOT NULL auto_increment,
      `count` int(6) NOT NULL default '0',
      PRIMARY KEY  (`count_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
    
    INSERT INTO `hitCounter` VALUES (1, 0);
    


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Alternative to Ziycons idea, you don't have to use a database, you could use a flat text file. Less mess, more success! :D

    I'm feeling cheesy...


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Mirror wrote:
    Alternative to Ziycons idea, you don't have to use a database, you could use a flat text file. Less mess, more success! :D

    I'm feeling cheesy...
    True. try looking at XML files if your going to go this route!


  • Closed Accounts Posts: 68 ✭✭nuada


    http://statcounter.com/ always worked well for me.
    Or if you do have hosting with php there are tons of scripts on http://hotscripts.com


  • Advertisement
  • Closed Accounts Posts: 164 ✭✭defenstration


    Ziycon wrote:
    If you do, you can create your own basic counter:

    Basicly everytime someone goes to a page call the hitCounter function and it will add 1 to the table in the DB!
    [PHP]<?php
    function hitCounter()
    {
    mysql_query("UPDATE hitCounter SET count=(count + 1) WHERE count_id=1");
    }
    ?>[/PHP]
    CREATE TABLE `hitCounter` 
    (
      `count_id` int(3) NOT NULL auto_increment,
      `count` int(6) NOT NULL default '0',
      PRIMARY KEY  (`count_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
    
    INSERT INTO `hitCounter` VALUES (1, 0);
    

    Turns out that I do have php on my host. So how exactly do I go about using your php code? Do I insert it in just before the </BODY> tag? What else do I need to do - do I have to create some text file in the database to hold the figure or something? Surely I need to declare hitCounter somewhere?
    Thanks in advance.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Ok, here's what you gotta do.

    1) Create a page called counter.php. Put this code into it:
    [php]
    <?php
    $count_my_page = ("hitcounter.txt");
    $hits = file($count_my_page);
    $hits[0] ++;
    $fp = fopen($count_my_page , "w");
    fputs($fp , "$hits[0]");
    fclose($fp);
    echo $hits[0];
    ?>
    [/php]

    2) Create a text file called hitcounter.txt. Do nothing with that.

    3) Write the line [php]<? include('counter.php'); ?>[/php] wherever it is that you want to display the counter. Presumably this would be the footer?

    Done!


  • Closed Accounts Posts: 164 ✭✭defenstration


    Tried that Mirror but unfortunately nothing is happening. No counter is appearing on the webpage, although that is fine cos if anything I'd prefer to have the number just mapped to a text file or sumthin than appearing on the page itself. But the text file hitcounter.txt is completely empty, even after a few visits to the page (where I put the code from the second segment in your reply).
    Not sure how to go about creating the counter.php file - that could be the problem. Originally, I had it just as a text file counter.php.txt (even after I renamed it to try and take out the .txt extension). When that didn't work, I created a .htm file , put in your code (1st bitta code in your reply) and renamed the .htm file to counter.php. Still nothing happening though.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    It's really quite simple. And there shouldn't be any issues creating the files.... but I've gone and created them for you. So just extract the two files in to your root directory and then on your home page, or any page you want as long as it's i the root directory, add the code

    [php]
    <?php include('counter.php'); ?>
    [/php]

    Now OBVIOUSLY the line of code above must go in to a .php file!

    And if that doesn't work I give up...


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Wouldn't you have to set the file permissions of hitcounter.txt to read and write (eg chmod 666 hitcount.txt )


  • Closed Accounts Posts: 164 ✭✭defenstration


    Mirror wrote:
    It's really quite simple. And there shouldn't be any issues creating the files.... but I've gone and created them for you. So just extract the two files in to your root directory and then on your home page, or any page you want as long as it's i the root directory, add the code

    [php]
    <?php include('counter.php'); ?>
    [/php]

    Now OBVIOUSLY the line of code above must go in to a .php file!

    And if that doesn't work I give up...

    Right, the page I want to count the hits on is my index.htm so are you saying that should now be changed to index.php? What I did was I opened index.htm -> View -> Source. Then when the source opened, I saved that as index.php. I replaced the index.htm on my host with the new index.php. I also copied your two files over (all my files are in the root directory). But now when I access my site, nothing appears but a blank page!


  • Closed Accounts Posts: 164 ✭✭defenstration


    I've attached here the code of my index.htm
    Maybe you could just do the needful yourself, cos I dunno what I'm doing wrong.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    You can't have two index pages. You didn't need to do any of that stuff. All you need to do is rename your index.htm page, not view source, copy, paste or any of that. Just rename your index.htm page to index.php, with that line of code in it, and the other two files in the same directory and that's it.


Advertisement