Explore the community Forums Lectora Lectora Questions & Answers PHP Script to Send Test Results from Lectora to a MySql Database

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #264920 Score: 0
    Profile photo of msproul
    msproul
    Member
    @msproul

    Here is my attempt to amend an asp script called saveresults.asp which was provided by Trivantis. The thing I have changed from the original is the connection method, which they use DSN. I also changed the variable name to username. The database TestResults.mdb is in a folder on the database called Lectora I get the following error:-I/O Error, cannot send results: Server returned http response code:500 for URL http:/www.trainnc.org/Lectora/saveresults.aspThe database and the asp file are in the same directory as is the test.< %@ Language=VBScript %>< %'Get the parameters posted from the test'testid=Request.Form("TestID")testname=Request.form("TestName")score=Request.form("Score")username=Request.form("Name")numQuestions=Request.form("NumQuestions")passingGrade=Request.form("PassingGrade")trueFalse=Request.form( "TrueFalse" )multipleChoice=Request.form( "MultipleChoice" )'Validate that this is actually from a Lectora test'if testname="" Or score="" Or username="" Or numQuestions="" Or passingGrade="" Or trueFalse="" Or multipleChoice="" then    Response.Write "”    Response.Write “Failure ”    Response.Write “”    Response.Write “STATUS=500”    Response.Write “
    ”    Response.Write “Could not parse test results due to a parameter error.”    Response.Write ““else    ‘Write the results to an access database’    ‘ First let us create Connection and Recordset objects’     Dim objDbConn     Set objDbConn = Server.CreateObject(“ADODB.Connection”)     objDbConn.Open “DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=” & Server.MapPath(“TestResults.mdb”)      ‘ Now, create the SQL statement’     sSQL = “INSERT INTO Result(TestID,TestName,PassingGrade,NumQuestions,MultipleCho ice,TrueFalse,Name,Score)      VALUES ( ‘” & testname & “‘, ” & passingGrade & “, ” & numQuestions & “, ” & multipleChoice & “, ”      & trueFalse & “, ‘” & username & “‘, ” & score & “)”     ‘ Execute the SQL statement, and set the recordset object’     ‘ to the result of this execution. We obtain the resulting’     ‘ records in Rs object’     Set Rs = Conn.Execute(sSQL)     ‘ Close the Recordset object and destroy it’     Set Rs = Nothing     ‘ You might want to release the resources for connection object, ‘     ‘ unless you want to use the same connection again in the later code’     Conn.Close     Set Conn = Nothing    ‘The response is optional, it is good for debugging’    Response.Write “”    Response.Write “Success ”    Response.Write “”    Response.Write “STATUS=200”    Response.Write “
    ”    Response.Write(sSQL)    Response.Write “
    ”    Response.Write “Success.”    Response.Write ““end if%>I’m sure I’ve messed something up by dabbling so apologies for my scripting knowledge, so as always my sincere thanks to anyone who can help.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.