Forums

ASP

This topic is locked

Link visits Error please Help.

Posted 24 Sep 2008 09:18:00
1
has voted
24 Sep 2008 09:18:00 Ishfaak Aha posted:
Hi can some one please help me to sort this pelase.....

I got this code and it has made the primary key as URL and this way is not the best So I added a ID field to that I can modyfy by the id to check the "Links Views or Hits". THsi works, and goes to the desired page with the line (redirect.asp?url=) whick redirects to to get the No of views per link and goes to the link.

&lt;a href="Javascript<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>opdbDes('redirect.asp?url=viewdiscription.asp?ID=&lt;%=(rsClicks.Fields.Item("ID".Value)%&gt;')"&gt;More&lt;/span&gt;&lt;/a&gt;

The page begins with clickview.asp: the only thing is when include the ID as the primary key the views are added when click, but it adds a extra table or column each time the link is clicked, with a different location, what do I have to do if to add this to a ID please?

Here is the code: clickview.asp

&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;%
Dim MM_connClicks_STRING
MM_connClicks_STRING = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("clickcounts.mdb")
%&gt;
&lt;%
Dim rsClicks
Dim rsClicks_numRows

Set rsClicks = Server.CreateObject("ADODB.Recordset"
rsClicks.ActiveConnection = MM_connClicks_STRING
rsClicks.Source = "SELECT * FROM SiteClicks"
rsClicks.CursorType = 0
rsClicks.CursorLocation = 2
rsClicks.LockType = 1
rsClicks.Open()

rsClicks_numRows = 0
%&gt;
&lt;%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsClicks_numRows = rsClicks_numRows + Repeat1__numRows
%&gt;
&lt;%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim rsClicks_total
Dim rsClicks_first
Dim rsClicks_last

'set the record count
rsClicks_total = rsClicks.RecordCount

' set the number of rows displayed on this page
If (rsClicks_numRows &lt; 0) Then
rsClicks_numRows = rsClicks_total
Elseif (rsClicks_numRows = 0) Then
rsClicks_numRows = 1
End If

' set the first and last displayed record
rsClicks_first = 1
rsClicks_last = rsClicks_first + rsClicks_numRows - 1

' if we have the correct record count, check the other stats
If (rsClicks_total &lt;&gt; -1) Then
If (rsClicks_first &gt; rsClicks_total) Then
rsClicks_first = rsClicks_total
End If
If (rsClicks_last &gt; rsClicks_total) Then
rsClicks_last = rsClicks_total
End If
If (rsClicks_numRows &gt; rsClicks_total) Then
rsClicks_numRows = rsClicks_total
End If
End If
%&gt;

&lt;%
' *** Recordset Stats: if we don't know the record count, manually count them

If (rsClicks_total = -1) Then

' count the total records by iterating through the recordset
rsClicks_total=0
While (Not rsClicks.EOF)
rsClicks_total = rsClicks_total + 1
rsClicks.MoveNext
Wend

' reset the cursor to the beginning
If (rsClicks.CursorType &gt; 0) Then
rsClicks.MoveFirst
Else
rsClicks.Requery
End If

' set the number of rows displayed on this page
If (rsClicks_numRows &lt; 0 Or rsClicks_numRows &gt; rsClicks_total) Then
rsClicks_numRows = rsClicks_total
End If

'set the first and last displayed record
rsClicks_first = 1
rsClicks_last = rsClicks_first + rsClicks_numRows - 1

If (rsClicks_first &gt; rsClicks_total) Then
rsClicks_first = rsClicks_total
End If
If (rsClicks_last &gt; rsClicks_total) Then
rsClicks_last = rsClicks_total
End If

End If
%&gt;

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Clickthroughs&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;

&lt;script language="JavaScript" type="text/JavaScript"&gt;
&lt;!--
function mark(face,field_color,text_color){
if (document.documentElement){//if browser is IE5+ or NS6+
face.style.backgroundColor=field_color;
face.style.color=text_color;
}
}
//--&gt;
&lt;/script&gt;

&lt;style type="text/css"&gt;
&lt;!--
a {
font-family: Tahoma;
color: #000000;
text-decoration: none;
}
a:hover {
font-family: Tahoma;
color: #FF0000;
text-decoration: none;
}
--&gt;
&lt;/style&gt;


&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Begin
function PopdbDes(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=438,left = 330,top = 213');";
}
// End --&gt;
&lt;/script&gt;


&lt;/head&gt;

&lt;body&gt;
&lt;div align="center"&gt;&lt;strong&gt;&lt;font size="4" face="Tahoma"&gt; Website Click through for edit&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div align="center"&gt;&lt;br&gt;
&lt;table width="65%" border="0"&gt;
&lt;tr&gt;
&lt;td&gt; &lt;div align="right"&gt;&lt;font size="1" face="Tahoma"&gt;
Showing a total of : &lt;%=(rsClicks_total)%&gt; links &lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;table width="65%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table width="699" border="0" cellspacing="1"&gt;
&lt;tr bgcolor="#3399CC"&gt;
&lt;td width="21%"&gt; &lt;font color="#FFFFFF"&gt;Name&lt;/font&gt;&lt;/td&gt;
&lt;td width="15%"&gt; &lt;font color="#FFFFFF"&gt;Position&lt;/font&gt;&lt;/td&gt;
&lt;td width="11%"&gt; &lt;font color="#FFFFFF"&gt;Salary&lt;/font&gt;&lt;/td&gt;
&lt;td width="14%" align="center"&gt;
&lt;font face="Times New Roman"&gt;URL&lt;/font&gt;&lt;/td&gt;
&lt;td width="8%"&gt;
&lt;b&gt;
&lt;font face="Arial" size="2" color="#FFFFFF"&gt;Age&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;td width="25%"&gt; &lt;div align="center"&gt;&lt;font color="#FFFFFF" size="2" face="Tahoma"&gt;
&lt;strong&gt;Click through for Description&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsClicks.EOF))
%&gt;
&lt;tr bgcolor="#FFFFFF" onMouseOver="mark(this,''#FFFF99'',''#000000'')"
onMouseOut="mark(this,''#FFFFFF'',''#000000'')"&gt;
&lt;td width="21%"&gt;&lt;font size="1" face="Arial"&gt;&lt;%=(rsClicks.Fields.Item("DBName".Value)%&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td width="15%"&gt;&lt;font size="1" face="Arial"&gt;&lt;%=(rsClicks.Fields.Item("DBposition".Value)%&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td width="11%"&gt;&lt;font size="1" face="Arial"&gt;&lt;%=(rsClicks.Fields.Item("DBsalary".Value)%&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td width="14%" align="center"&gt;&lt;a href="redirect.asp?url=&lt;%=(rsClicks.Fields.Item("URL".Value)%&gt;" target="_blank"&gt;
&lt;font face="Arial" size="1"&gt;&lt;%=(rsClicks.Fields.Item("URL".Value)%&gt;&lt;/font&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td width="8%"&gt;&lt;font size="1" face="Arial"&gt;&lt;%=(rsClicks.Fields.Item("DBage".Value)%&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td width="25%"&gt;

&lt;p align="center"&gt;&lt;font face="Arial" size="1"&gt;&lt;span style="font-size: 8.0pt; font-family: Arial"&gt;More&lt;/span&gt;&lt;/a&gt;
&lt;b&gt;&lt;font color="#FF6600"&gt;(&lt;/font&gt;&lt;/b&gt;views:&lt;%=(rsClicks.Fields.Item("ClickCount".Value)%&gt;&lt;b&gt;&lt;font color="#FF6600"&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>&lt;/font&gt;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsClicks.MoveNext()
Wend
%&gt;
&lt;/table&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsClicks.Close()
Set rsClicks = Nothing
%&gt;


The redirect redirect.asp code is:


&lt;%
SiteURL = Request.QueryString("URL"

If Len(SiteURL) &gt; 0 Then
Set objConn = CreateObject("ADODB.Connection"
objConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/view-addeddw/clickcounts.mdb" & ";Persist Security Info=False"

' If the URL is already in the database an error will be thrown and we perform an UPDATE Instead of a INSERT.

on error resume next
objConn.Execute "INSERT INTO SiteClicks(URL,ClickCount) VALUES('" & SiteURL & "',1)"
If Err.Number &lt;&gt; 0 Then
objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'"

End If
objConn.Close
Set objConn= Nothing
Response.redirect SiteURL
End If

'End If

%&gt;


Can Some one please help me to sort this by ID.

Awaiting your favorable reply.

Thank you.




Hello

Reply to this topic