Dear Monks I have the following script, that reads a list of columns from my database and then geenrates a list of checkboxes and two submit buttons in order for me to send the selected checkboxes names as parameters to a second script my first script is :
#!/usr/bin/perl use DBI; use CGI ':standard'; use strict; use warnings; my $q= CGI->new(); print header, start_html('Advanced Search'); # Connect to the database my $dbh = DBI->connect('DBI:mysql:mirnas', 'root', 'pass') or die "Couldn't open database: $DBI::errstr; stopped"; # Getting all the column names and creating checkboxes for them my $table = '07_11_09'; my $sth = $dbh->prepare("SELECT * FROM $table where 1=0 "); $sth->execute; my @cols = @{$sth->{NAME}}; # or NAME_lc if needed #print "@cols\n"; $sth->finish; #creating and printing the checkboxes print checkbox_group(-name=>'fields_to_search', -values=>\@cols # Your array above ); #storing the parameters from the checkboxes my @fields_to_search=param('fields_to_search'); #creating the submit boxes print'<FORM ACTION="http://sirocco/cgi-bin/tissue_search.pl" METHOD="POST">'; #here it submits the sel +ected parameters to a search form print br, '<INPUT TYPE = "SUBMIT"VALUE="Click To Submit">'; print '<INPUT TYPE="RESET"VALUE=Clear>'; print '</FORM>', end_html;
I want my second script , for starters to just print which tissue names I have selected. I am fdoing the following, but to no result, it prints that I have selected 0 tissues
#!/usr/bin/perl use strict; use CGI ':standard'; use DBI; my $q= CGI->new(); print $q->header(), $q->start_html(); my $dbh = DBI->connect('DBI:mysql:mirnas', 'root', 'bi0u90ee') or die "Couldn't open database: $DBI::errstr; stopped"; # Getting all the column names and creating checkboxes for them my $table = '07_11_09'; my $sth = $dbh->prepare("SELECT * FROM $table where 1=0 "); $sth->execute; my @cols = @{$sth->{NAME}}; # or NAME_lc if needed #print "@cols\n"; $sth->finish; my @responce; my $tissues; @responce = param('fields_to_search'); $tissues = $#responce +1; print "<FONT SIZE =4> You have selected the following $tissues tissues +"; print "</FONT>", end_html;
Could somebody notice and let me know what I am doing wrong? I am pretty sure that I am not passing the correct parameters around Thank you all for your help

In reply to new to cgi and problems by gogoglou

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.