Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


FP counter visibility

Posted on 2004-10-30
Medium Priority
Last Modified: 2013-12-24
I run several web sites each with a FP hit counter. Idealy I would like each site to deposit the counter reading into a table from which a graph of hits vs day would be drawn. However this looks like a two month programming job. I will settle for

some ideas on how to make the counter readabel only by me.

E-mail me once a day, print hits in the background color, print hits on an unlisted page, or ?
Question by:aburr
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 14

Accepted Solution

hhammash earned 500 total points
ID: 12453444

Here is a hit counter that i based on ASP and can write to the database,  you can view the counter or not.  How to install it? it is very easy.

1- Create a new page in Frontpage
2- Switch to HTML view
3- Delete all the HTML code that you see
4- Copy the following code into the HTML area which is blank now.  Copy the code as it is to Notepad then from notepad to the new blank html page that you have created in Frontpage.  Copy the code between the ---------------- lines.  

------------------------------------ The CODE Below This --------------------------------------

'*     ASP 101 Sample Code - http://www.asp101.com/    *
'*                                                     *
'*   This code is made available as a service to our   *
'*      visitors and is provided strictly for the      *
'*               purpose of illustration.              *
'*                                                     *
'*      http://www.asp101.com/samples/license.asp      *
'*                                                     *
'* Please direct all inquiries to webmaster@asp101.com *

<strong><%= RetrieveAndIncrementCount() %></strong>
' I placed this in a function so I wouldn't have to worry about
' any namespace collisions.  For example... if this was inline
' code and someone named a variable strSQL in a file this file
' gets included into you'd get an error.  This way you don't and
' there's no chance of the variables overwriting one another!
Function RetrieveAndIncrementCount()
      ' From adovbs.inc:
      Const adOpenKeyset = 1
      Const adLockPessimistic = 2
      Const adCmdText = &H0001

      ' Local variables
      Dim strFilename
      Dim strSQL
      Dim rsCounter
      Dim iCount

      'Get filename and build SQL query
      strFilename = Request.ServerVariables("SCRIPT_NAME")
      strSQL = "SELECT page_name, hit_count FROM hit_count WHERE page_name='" & strFilename & "';"

      'Open our recordset
      Set rsCounter = Server.CreateObject("ADODB.Recordset")
      'Access version:
      rsCounter.Open strSQL, _
      "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("counter_db.mdb") & ";", _
      adOpenKeyset, adLockPessimistic, adCmdText
      ' SQL Server version:
      'rsCounter.Open strSQL, "Provider=SQLOLEDB;Data Source=;" _
      '      & "Initial Catalog=samples;User Id=samples;Password=password;" _
      '      & "Connect Timeout=15;Network Library=dbmssocn;", _
      '      adOpenKeyset, adLockPessimistic, adCmdText

      ' If we've got a record then we read the current value
      ' If we don't then we create one, set the filename, and start at 0
      If rsCounter.EOF Then

            iCount = 0

            rsCounter.Fields("page_name").Value = strFilename

            iCount = rsCounter.Fields("hit_count").Value
      End If

      ' Increment the count and update the DB
      rsCounter.Fields("hit_count").Value = iCount + 1

      ' Close our connection
      Set rsCounter = Nothing

      ' Return the count (pre-incrementation).
      RetrieveAndIncrementCount = iCount
End Function

--------------------------------- END of CODE ----------------------------------------

5- Save the page as

6- Create a database in Access to have the following:
Database name: counter_db.mdb
Database table name: hit_count
Database table fields: page_name (text), hit_count(numeric)

7- Import the database into your webfolder

8- Make sure that the database has permission for Everyone and Internet Guest Account to write to the database.  Grant write permissions for Everyone and Internet guest account.

9- Open the page that you want to place the hit counter on

10- Copy the following line to the body of the page
<!--#include file="counter_db_inc.asp"-->
You can put this line in the body of each and every page you want to count  because the counter can count the hits for each page and in the page_name field,  the code will write the name of the page and the total hits.

I modified the code to be used for Access database.

Just create the database as I told you
Save it
Give it permissions
Stick to the field names and page names I gave you

Withing 10 minutes you will have your own counter.

If you don't want to display the counter for users you can change this line which is at the top of the long code:

<strong><%= RetrieveAndIncrementCount() %></strong>

<strong><font color="#FFFFFF"><%= RetrieveAndIncrementCount() %></font></strong>

This will make the font color white on a white page.  Change the color according to the background color of your page.

This is a very nice counter,  it counts the hits of every page when it is visited.

Please do not hesitate to ask.


LVL 14

Expert Comment

ID: 12454119
You can use the database to create any chart you want.

Also,  I gave you two essential fields in the database that get populated by the code,  you can add other fileds like time and date which will have a default value.  So,  you can tell whenever the page is visited.

LVL 14

Expert Comment

ID: 12509313
You better try this counter,  it is easy to install and it will work fine.  I tried it myself.  It is very informative and you can use it for later statistics.

LVL 27

Author Comment

ID: 12510429
answer looks good. I am half way down the page the bottom of which I will place the counter
LVL 14

Expert Comment

ID: 12512592
Good luck

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question