in reply to Re^7: html checkbox and perl cgi
in thread html checkbox and perl cgi

Got it, thank you so much. So I tried it and the print statements were displayed correctly once I clicked submit, so that part is ok. I guess the problem is with the query to mySQL?

Replies are listed 'Best First'.
Re^9: html checkbox and perl cgi
by tangent (Parson) on Jan 18, 2014 at 23:27 UTC
    You still haven't said what the problem is?
      Oh I'm sorry, the problem is that when I click submit, the results of the query to the database aren't displayed. The only thing displayed is the borders of the Table that I had asked to be printed in the CGI file. So the problem has to be with the "select" statement in the cgi file that queries mySQL right?
        First I would try the DB query with hardcoded values - ignore the form inputs and make a query that you know will work and see what happens. When you have that working add some print statements - first to the $db_query that you construct from the form parameters to make sure it is what you think it is (examine it closely), and then the $total to make sure you are getting something back. And so on...
        $db_query = "SELECT ST.sno_name,HT.homolog_name FROM sno_Table ST, +Homolog_Table HT,sno_Homologs SH,Organism O WHERE ST.sno_id=SH.sno_id AND SH.homolog_id=HT.homolog_id AND HT.org_i +d=O.org_id and (ST.family=$family) and O.organism='$TB'"; print "db_query: $db_query<br>"; # add this my $sth = $dbh->prepare($db_query); $sth->execute(); my $total = $sth->rows; print "total rows: $total<br>"; # add this
        Also, fix your td tags:
        <td>$sno_name</d> should be: <td>$sno_name</td>