Print Page | Close Window

Page Counter

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2691
Printed Date: 29 March 2026 at 7:47pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Page Counter
Posted By: Misty
Subject: Page Counter
Date Posted: 14 May 2003 at 12:00am

I need some help with fixing a page counter. It worked on my web site when I was with another web hosting company. I've been messing with the code. Please take a look at the code below. Please look at the code that is in blue. I need help with fixing this.

 

<%

Dim strPath, File, file2, x,liCount, j ,resfile, d, i ,fl, FileName

'strPath = "counter.txt"

   'Set connection details
    'strPath = Server.MapPath(".")
    'strPath = Replace(strPath,"html","database")
    'FileName = "counter.txt"

   

strPath = "D:\www\database\counter.txt"

Set File = Server.CreateObject("Scripting.FileSystemObject")

set file2=File.OpenTextFile(strPath)

x=file2.readline

 

set resfile = File.createTextFile (strPath)

resfile.writeline(x+1)

liCount=Cstr(x+1)

j = Len(liCount)

d=9 - j

%>

<%

        For i=1 to d step 1

         Response.Write ("<IMG SRC='/digits/0.gif'>")

        Next

  For  i=1 to j step 1

   fl="" + Mid(liCount, i , 1) + ".gif"

   Response.Write ("<IMG SRC=") & (fl) & ">"

 Next

%>




Replies:
Posted By: Mart
Date Posted: 14 May 2003 at 10:04am
What happens... an error, broken images?


Posted By: Mart
Date Posted: 14 May 2003 at 10:06am

IF its a broken image try

fl="""" + Mid(liCount, i , 1) + """.gif"

   Response.Write ("<IMG SRC=") & (fl) & ">"



Posted By: Misty
Date Posted: 14 May 2003 at 10:34am

I am sorry that I was not specific enough. Here's the error message that I got:

Microsoft VBScript runtime error '800a004c'

Path not found

/count.asp, line 11

My text file is in a database folder. There are HTML and database folders.  

 



Posted By: Mart
Date Posted: 14 May 2003 at 11:25am

You have commented out these lines

'strPath = "counter.txt"

   'Set connection details
    'strPath = Server.MapPath(".")
    'strPath = Replace(strPath,"html","database")
    'FileName = "counter.txt"

 change that block of code to:

strPath = "counter.txt"

  'Set connection details 
    strPath = Server.MapPath(".")
    strPath = Replace(strPath,"html","database")
    FileName = "counter.txt"



Posted By: Misty
Date Posted: 15 May 2003 at 5:43pm

I've worked on this page counter. Please look at the code of line in blue. Everything works except for one thing. This is strange, but I get a broken image for numbers that are above 0. The zeros will show up. I got the code from http://www.programmersresource.com/articles/counter.asp - http://www.programmersresource.com/articles/counter.asp .

Here's my new code:

<%

Dim strPath, File, file2, x,liCount, j ,resfile, d, i ,fl

'strPath = "counter.txt"

strPath = "D:\inetpub\wwwroot\anywhere.com\database\counter.txt"

Set File = Server.CreateObject("Scripting.FileSystemObject")

set file2=File.OpenTextFile(strPath)

x=file2.readline

 

set resfile = File.createTextFile (strPath)

resfile.writeline(x+1)

liCount=Cstr(x+1)

j = Len(liCount)

d=7 - j

%>

<%

        For i=1 to d step 1

         Response.Write ("<IMG SRC='/images/Num0.gif'>")

        Next

  For  i=1 to j step 1

   fl="Num" + Mid(liCount, i , 1) + ".gif"

   Response.Write ("<IMG SRC=") & (fl) & ">"

 Next

%>

 



Posted By: Misty
Date Posted: 15 May 2003 at 5:56pm

You can ignore this posting. I just put the images in the folder that the html page was in. I removed the images from the code of line. It works now.

However, I still need help to fix the code in the "New Page Counter". It's a different page counter from this one.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net