<% linkid = Request.Querystring("linkid") ' Validate linkid If Not IsNumeric(linkid) Or CLng(linkid) < 1 Then Response.Redirect("displayknowledgebase.asp") Response.End End If ' Get the link URL strSQL = "SELECT linkurl FROM knowledgebase WHERE linkid=" & CLng(linkid) set rs = objconn.Execute(strSQL) If rs.EOF Then rs.Close Set rs = Nothing objconn.Close Response.Redirect("displayknowledgebase.asp") Response.End End If linkurl = rs("linkurl") & "" rs.Close Set rs = Nothing ' Check if linkurl is empty - if so, redirect back to article instead of looping If linkurl = "" Then objconn.Close Response.Redirect("displayknowledgearticle.asp?linkid=" & CLng(linkid)) Response.End End If ' Update click counter only if we have a valid URL strSQL = "UPDATE knowledgebase set clicks=clicks + 1 Where Linkid=" & CLng(linkid) objconn.Execute(strSQL) objconn.close %>