MySQL Forums
Forum List  »  Perl

What could cause an "insert" to choke?
Posted by: David Flores
Date: April 25, 2007 08:16AM

Ok, so here's the story. I'm writing an online quiz that's currently in testing. Questions are pulled from a table in a MYSQL database and results are stored in another table. Test takers answer a set of preliminary questions, and add any comments they think we might find useful in a text field. Then they complete a multiple choice test. At the end of the test, results are stored in a table, along with all sorts of other statistical info (what questions they saw, which ones they got right, etc.)

So far, all has gone well and all test takers who have completed the quiz have gotten results, except for one case. One student took the test, but her result was not stored. And this case troubles me because she actually took the test twice, on two different computers, on two different days. This makes me suspect that it was some particular value that she filled-in both times that caused the problem. (Oddly, when I oversaw her trying it a third time, all worked as expected).

This is the actual code that updates the database:


unless ($version eq "Beta")
{

$dbh = DBI->connect( $url, $user, $password ) or die "Failure!<p>";
$sth = $dbh->prepare("insert into placements values ( NULL,\'$idnum\', \'$lnam\', \'$fnam\', \'$queshis\', \'$anshis\', \'$random[17]\', \'$reclev\', \'$startime\', \'$endtime\', \'$prevital\', \'$lastclass\', \'$otherexposure\',\'$furtherinfo\',NULL)");
$sth->execute();
$sth->finish;
$dbh->disconnect;


}

So are there any common text characters that could cause the "insert" statement to fail? These values would most likely be found in the "$otherexposure" variable which is passed to the program from the text field in the preliminary questions section. I'd like to know the answer so that I can strip them out before sending them to the database. Currently I don't do any text processing on the variable in question.

Options: ReplyQuote


Subject
Written By
Posted
What could cause an "insert" to choke?
April 25, 2007 08:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.