2

私はしばらくの間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

この問題は「whileNOTループ」のどこかにあると確信していますが、ASPについては十分に理解できていません。

私は知っています:-使用されているMySQL情報は正しいです-コードはwhileループが削除されたときに機能します。

どんな助けでも本当にありがたいです。

4

1 に答える 1

0

oRS = oConnection.Execute(を設定する必要がありますoRS = oConnection.Execute(– Gaby aka G. Petrioli

于 2012-11-26T21:07:57.133 に答える