Forums
This topic is locked
How can I add a hit counter to my website
Posted 27 Feb 2003 11:03:38
1
has voted
27 Feb 2003 11:03:38 kirsty burgoine posted:
I want to add a simple hit counter to my website. I've tried adding an asp counter but for some reason it only updates once then never updates again from any computer or connection. This is the code I used:<%on error resume next
' Create a server object
set fso = createobject("scripting.filesystemobject"

' Target the text file to be opened
set act = fso.opentextfile(server.mappath("asp_count.txt"

' Read the value of the text document
' If the text document does not exist then the on error resume next
' will drop down to the next line
counter = clng(act.readline)
' Add one to the counter
counter = counter + 1
' Close the object
act.close
' Create a new text file on the server
Set act = fso.CreateTextFile(server.mappath("asp_count.txt"

' Write the current counter value to the text document
act.WriteLine(counter)
' Close the object
act.Close
' Write the counter to the browser as text
Response.Write counter
%>
Can anyone help? Check www.bandm.co.uk at the very bottom of the page to see what I mean.