I’ve been trying to get some ASP code to work for a while and simply can’t (I’m a PHP guy and contracted someone to do this for me, but he refuses to answer emails now). So I was wondering if someone could help me troubleshoot an issue I’m having and perhaps explain what the issue is with this code. Here is the code:
'------------ Connect to MySQL --------------------------
sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=" & sServer & "; DATABASE=" & sDBName &"; UID=" & sDBUser & ";PASSWORD=" & sDBPass & "; PORT=3306;"
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open(sConnection)
Set oRS = Server.CreateObject("ADODB.Recordset")
'------------ Connect to MySQL --------------------------
'Checks if the cookie exists
sCookieValue = Request.Cookies(sCookieName)
bCookieFound = CBool(Len(sCookieValue) > 0)
if bCookieFound then
oRS = oConnection.Execute("SELECT * FROM sessions WHERE id=" & sCookieValue )
Dim bSDFound
Dim sDate
bSDFound = false
Do while NOT oRS.EOF
bSDFound = true
sDate = oRS("date")
oRS.MoveNext ' Next record
Loop
' Check if found in the DB
if bSDFound then
'Convert from universal Date format
Dim dateDB
dateDB = CDate(Mid(sDate, 1, 10) & " " & Mid(sDate, 12, 8))
'Check if is longer than 1 hour old
if DateDiff("n", dateDB, Now) > 60 then
Response.Redirect urlLogin
else
'If it is not older than an hour, update it to the current timestamp and redirect
oConnection.Execute("UPDATE sessions set date=Now() WHERE id=" & sCookieValue )
Response.Redirect urlWelcome
end if
else
Response.Redirect urlLogin
end if
else
Response.Redirect urlLogin
end if
I’m quite certain that the issue is somewhere in the “while NOT loop”, but I don’t know enough about ASP to figure it out.
I do know:
– MySQL information being used is correct,
– The code works when the while loop is removed.
Any help is truly appreciated.
oRS = oConnection.Execute( should be set oRS = oConnection.Execute(
– Gaby aka G. Petrioli