...

View Full Version : HTTP_REFERRER to database problem



Detonate
01-13-2005, 05:33 PM
I have a problem with my script, it doesn't enter the server variable HTTP_REFERRER into the database field correctly; it only ever enters the domain as "Not Referred" :


<% Dim strURL, arrURL, x, i, refURL, refDomain, currURL
strURL = LCASE(Request.ServerVariables("HTTP_REFERRER"))
If strURL > "" then
'Split example into array based on / char
arrURL = Split(strURL, "/")
refDomain = arrURL(0)&"//"&arrURL(2)
For i = 3 to UBound(arrURL)
refURL = refURL&"/"&arrURL(i)
Next
Else
refDomain = "Not Referred"
refURL = ""
End If
currURL = "http://"&Request.ServerVariables("SERVER_NAME")&Request.ServerVariables("URL")

Set objReferrer = Server.CreateObject("ADODB.Recordset")
objReferrer.ActiveConnection = "dsn=INVITEDB"
objReferrer.Source = "SELECT * FROM Referrer_Stats WHERE LoggedFromPage = '"&currURL&"' AND Ref_Domain = '"&refDomain&"' AND Ref_URL = '"&refURL&"'"
objReferrer.CursorType = 0
objReferrer.CursorLocation = 2
objReferrer.LockType = 2
objReferrer.Open()

objReferrer_numRows = 0

If Not objReferrer.EOF Or Not objReferrer.BOF Then
objReferrer("Referrals") = (objReferrer.Fields.Item("Referrals")+1)
objReferrer.Update
Else
objReferrer.AddNew
objReferrer("LoggedFromPage") = currURL
objReferrer("Ref_Domain") = refDomain
objReferrer("Ref_URL") = refURL
objReferrer("Referrals") = 1
objReferrer.Update
End If
%>

can anyone see anything wrong here?
tia

ghell
01-14-2005, 10:33 AM
argh, messy, use
<%
For Each strServerVariable in Request.ServerVariables
Response.Write strServerVariable & "<br><br>" & Request.ServerVariables(strServerVariable) & "<hr>"
Next
%>

Detonate
01-17-2005, 10:29 AM
bah, a simple sp was all it was

thanks ghell :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum