hello , I have a quiz script. I randomly generates questions up to an
certain number ( what is ever set in the quiz name settings table) , passes
it ina variable to a grade.cgi.      the variable looks like  this
!34!56!5!67!     all question numbers seperated by a delimiter. all these
questions com from a mysql table. 
Everything works except for it misses the first question. The script pulls
the number , the db doesnt query for the answer, it continues on with the
rest of the grading fine.
 
help
 
 
 
$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 the number : $num1";
 
 
 
# my $sth1 = $dbh -> prepare("select * from tests where num  = ? ");       #
i tried these 
 
 
 
# $sth1 -> execute($num1) or die " unable to execute query ";
#  i tried these 
 
 
 
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();
 
 
 
 
____________________________________________________________________________
________________
output example
 
 



t0642k8 


Test results for Test : Exchange 

  _____  

this is the number : 486 
486      What two folders are available in Exchange Server?     
Correct answer is : CE   You answered  A        
The Reason              
        
this is the number : 564 
564      Which bindery attachments does the Internet Mail Service support:

Correct answer is : AC   You answered           
The Reason              
        
this is the number : 274 
274      Which are components of Exchange Server?       
Correct answer is : BD   You answered           
The Reason              
        
this is the number : 43 
43       How are schedule free and busy times handled by the Exchange
Server?         
Correct answer is : C    You answered           
The Reason              
        
 
 
 
thanks 
Jim Flaherty

Reply via email to