Does anyone have an Idea whats going on here , I have an array feeding a SQL Query, But it doesnt always come back with a success . What this query does it is on a Quiz web site . Students take quiz, variable is passed to grade.cgi. that variable is parsed with a while statement. and a variable is feed to the query. If the student takes 10 question, only 6 or 7 will get graded. I have red hat 7.2 and mysql 3.23 , is it possible the while statement executes to fast for the query ?? Code: ########################################## # connect to DB ############################ use DBI; my $database = "cram"; my $data_source = "DBI:mysql:$database"; my $username = "user"; my $password = "password"; $dbh =DBI ->connect($data_source, $username, $password) or die "cant connect to $data_source : my $dbh-> errstr\n";
while( $questions_asked =~ /!([^!]*)/g) { my $num1 = $1; print " This is a test: $num1<BR>"; # this statement for debug my $sth1 = $dbh -> prepare("select * from tests where num = '$num1' "); $sth1 -> execute or die " unable to execute query "; #$sth1 -> finish; my $array_ref = $sth1 -> fetchall_arrayref(); It would miss every other to every third one Help! thanks Jim