|
|
|
Need Simple Hit Counter
|
Original Message
|
Name: NarrowPathPilgrim
Date: January 15, 2005 at 22:23:49 Pacific
Subject: Need Simple Hit CounterOS: XP HomeCPU/Ram: 2.53 GH'z |
Comment: Hello, I am looking for a simple way to make a hit counter in HTML that displays the results in text format instead of using a graphic to display the results, all of the hit counters that I have seen just link you to a immage on some other server and I am looking for a way to do it without having to do that.
Report Offensive Message For Removal
|
|
Response Number 3
|
Name: Laler
Date: January 17, 2005 at 05:46:37 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)hi Zach, saw your post on the other thread then I got interested :D I did a search and here it is on the 1st result... .htaccess here is only meant to include the counter to every .html page... it has nothing to do with the counting process... you also need to have shell access to the server (I think), because you must run the installation file (and some configuration) directly... http://www.viaverio.com/support/virtual/web/cgi/lib/counter/ basically, to create "counters" you need a server-side scripting as SN long-explained in the other thread, CGI in this case... why not use PHP? it's less than 10 lines I think :) ^o^ are you in Asia? do you watch Animax Asia? Please Vote
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: cubesoft
Date: January 17, 2005 at 07:33:45 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)Try this http://www.digits.com/create.html. VERY NICE! I use this every time. --- Tommy Segoro CubeSoft Information Technology - Online Computer Store, Web Site Design, Software Development, Search Engine Optimization http://www.cubesoft.com.au info@cubesoft.com.au
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: NarrowPathPilgrim
Date: January 17, 2005 at 11:02:52 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)I need to use HTML for the main page but I could use PHP for another page and add some code into the HTML page to use the PHP file, Isn't that how most free hit counter services work?
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: Laler
Date: January 17, 2005 at 11:24:49 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)you sure you can't use index.php ? the whole page can be html, only the extension changed into .php then you can add let's say in a TD on the bottom-most table <td><?php include ("counter.php"); ?></td> ----- if you dont want to change the index file's extension, then there're other options too: 1. make the server parse .html with PHP (pure html wont be affected) by using .htaccess 2. use IFRAME on the place where you want the counter to appear, point that IFRAME to a PHP file... you can customize IFRAME to not showing border and put the same background color on the counter(.php) file so it'll match the index.htm file... 3. use javascript to work in conjunction with PHP... so a javascript code on your HTML page will call a php file which construct javascript code to _print_ the hit counter. ^o^ are you in Asia? do you watch Animax Asia? Please Vote
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: Laler
Date: January 18, 2005 at 16:00:32 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)try this one: create counter.php <?php session_start ();// get current hit $opFile = fopen ("counter.txt", "r"); $handle = fread ($opFile, filesize ("counter.txt")); fclose ($opFile); // if new session if (!isset ($_SESSION['hit'])){ // set session $_SESSION['hit'] = TRUE; // add the hit $handle = $handle + 1; // print javascript echo 'document.write("'.$handle.' Hits");'; // put new hit to db $opFile = fopen ("counter.txt", "w"); fwrite ($opFile, $handle); fclose ($opFile); // else }else{ // print only echo 'document.write("'.$handle.' Hits");'; } ?> then create counter.txt with number (let's say: 0) as its content... nothing more not even a single space (to make sure $handle + 1 won't produce error) then on your html page, put: <script language="JavaScript" src="counter.php" type="text/JavaScript"></script> at the place where you want the counter to appear... ----- I'm not really sure about this, about how will browser's javascript parser act on file extensions other than .js but I tested the above with IE & firefox and it's fine ----- the counter above use session (same browser session wont add the count) and dont forget to allow counter.txt to be writeable by all ^o^ are you in Asia? do you watch Animax Asia? Please Vote
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: Laler
Date: January 18, 2005 at 16:11:28 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)* about my 1st post above, the script is 9 lines long if we skip the php tag and dont use session :P ^o^ are you in Asia? do you watch Animax Asia? Please Vote
Report Offensive Follow Up For Removal
|
|
Response Number 10
|
Name: NarrowPathPilgrim
Date: January 19, 2005 at 10:33:16 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)Hmmm, I must be doing something wrong, it doesn't work for me, I am testing it on a windows server so the problem can't be file write permitions, Any Ideas?
Report Offensive Follow Up For Removal
|
|
Response Number 11
|
Name: Laler
Date: January 19, 2005 at 10:51:09 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)any error message? try putting error_reporting(E_ALL); on top of the script (before session start) and try calling it (counter.php) again from the browser, see what error comes up... it *could* be file permission... is it in your own PC or not? ^o^ are you in Asia? do you watch Animax Asia? Please Vote
Report Offensive Follow Up For Removal
|
|
Response Number 12
|
Name: NarrowPathPilgrim
Date: January 19, 2005 at 13:09:44 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)OK, now I get this error Line:2 Char:1 Code:0 Error:Syntax error URL:file://C:\WM\www\hitcounter\counter.html And Yes, it is hosted on my PC
Report Offensive Follow Up For Removal
|
|
Response Number 13
|
Name: NarrowPathPilgrim
Date: January 19, 2005 at 13:13:03 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)Sorry, it was my problem and I got it fixed, I was just running the file from the folder instead of running it thought the server. I should have known better!
Report Offensive Follow Up For Removal
|
|
Response Number 16
|
Name: Saucie_
Date: February 22, 2005 at 11:58:24 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)Hello, I have tried to use the script that was posted above, however it is not working. I created the files - counter.php, counter.txt and my test html page is countertest.htm all files are located in the root folder of my site. This is on an intranet site if that makes a difference. When I load the page in the browser (off the test server), I am getting the same error code - Line:2 Char:1 Code:0 Error:Syntax error URL:http://test/countertest.htm The counter.txt file is set to writable. I don't know why it is not working. Any help would be appreciated. Thanks.
Report Offensive Follow Up For Removal
|
|
Response Number 17
|
Name: Laler
Date: February 22, 2005 at 13:20:41 Pacific
Subject: Need Simple Hit Counter |
Reply: (edit)hi, you sure the webserver will run PHP correctly? maybe by testing it to run a simple php file: <?php echo 'hello world'; ?> save the above as test.php and try calling http://localhost/test.php I'm not really sure where did that error message refer to... what's in Line 2 of the file countertest.htm? what's showing when you call counter.php? (http://localhost/counter.php) it should be: document.write("some Hits"); ps: the script is meant for html pages to fetch the counter by using javascript, which is created by PHP... so if you can put php directly to your "html" pages (by changing .htm into .php), you can use another more simple way. --- siggy space for rent
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|