我一直试图让一些 ASP 代码工作一段时间,但根本做不到(我是一个 PHP 人,并与某人签约为我做这件事,但他现在拒绝回复电子邮件)。所以我想知道是否有人可以帮助我解决我遇到的问题,也许可以解释这段代码的问题所在。这是代码:
'------------ 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
我很确定问题出在“while NOT 循环”中,但我对 ASP 的了解还不够,无法弄清楚。
我知道: - 正在使用的 MySQL 信息是正确的, - 当 while 循环被删除时,代码可以工作。
任何帮助都非常感谢。