Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Counting Links with ASP

    Is it possible that when a link is click by the surfer a new window pops up with the website and link is counted in a database.

    I am trying to get it to have some links, and the most popular one at the top of the list.

    I have the connection to the database (dsn-less) and have a method of sorting the links its just counting the number of times press i am stuck on.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it work with meny link such as shoping site ,and each product has hit counter
    <a herf=productdisplay.asp?id>some product</a>

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry i have given the impression that i know more then you think.
    I have set the links up on a page as you said
    <a href="countLinks.asp?url=actual.url">link text</a>

    And am not really sure were to go from there.

    This is my guess
    <%
    Dim con, rs, strLink
    Set con = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset")
    con.Provider = "Microsoft.Jet.OLEDB.4.0"
    con.Open "Data Source = " & Server.MapPath ("db\mydatabase.mdb")

    Set rs = con.Execute("Select pageurl, hits From tuning Where URL = " & Request.Querystring("pageurl"))

    strLink = rs("link")
    Set rs = con.Execute("Update tuning Set hits_out = (hits_out + 1) Where pageurl = " & Request.Querystring("pageurl"))
    Set rs = Nothing
    con.Close
    Set con = Nothing
    Response.Redirect "http://" & strLink
    %>

  • #4
    New Coder
    Join Date
    Jun 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Microsoft JET Database Engine error '80040e10'

    No value given for one or more required parameters.

    /nimblenova/countLinks.asp, line 9 In Red

    is the error i get with that.

    From this

    <%
    Dim con, rs, strLink
    strLink = Request.Querystring("url")
    Set con = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset")
    con.Provider = "Microsoft.Jet.OLEDB.4.0"
    con.Open "Data Source = " & Server.MapPath ("db\mydatabase.mdb")

    Set rs = con.Execute("Update tuning Set hits_out = (hits_out + 1)
    Where pageurl = " & strLink)
    Set rs = Nothing
    con.Close
    Set con = Nothing
    Response.Redirect strLink
    %>

    I have made sure that in my database "hits_out" is there and i also have "PageURL" in there

  • #5
    New Coder
    Join Date
    Jun 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am not sure what this error means and how to solve it

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    just an alternative solution that updates link counts on the background while opening the link. This goes directly to the specified url (no redirection) without the user knowing countLinks.asp is executed on the background.

    <head>
    <script>
    function openURL(url){
    var count = new Image();
    count.src="countLinks.asp?url="+url;
    location.href=url;
    }
    </script>
    </head>
    <body>
    <a href="javascript:link1.asp">link 1</a>
    <a href="javascript:link2.asp">link 2</a>



    countLinks.asp:
    <%
    Dim con, rs, strLink
    strLink = Request.Querystring("url")
    Set con = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset")
    con.Provider = "Microsoft.Jet.OLEDB.4.0"
    con.Open "Data Source = " & Server.MapPath ("db\mydatabase.mdb")

    Set rs = con.Execute("Update tuning Set hits_out = (hits_out + 1) Where pageurl = " & strLink)
    Set rs = Nothing
    con.Close
    Set con = Nothing
    %>

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    sorry, maybe i was too eager to post it.
    here's the correct link:

    <a href="javascript:openURL('link1.asp')">link 1</a>
    <a href="javascript:openURL('link2.asp')">link 2</a>

  • #8
    New Coder
    Join Date
    Jun 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have now tried them both and its not working. I had a play with the script and its still didn't work.

    How can i verify my ADO code and i guess its somthing to do with the access database?

  • #9
    New Coder
    Join Date
    Jun 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That still shows this

    Microsoft OLE DB Provider for ODBC Drivers error '80004005'

    [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.

    /nimblenova/countlinks.asp, line 7

    so it just my connection to the database that is the problem

    Set con = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset")
    con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=URL=db\mydatabase.mdb"
    rs.Open "tuning", con, 2, 2, 2 ' adOpenDynamic, adLockPessimistic, adCmdTable

    I don't know what all the con, 2, 2, 2 ' adOpenDynamic, adLockPessimistic, adCmdTable means.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •