in reply to Re: RE. My earlier checkbox question(s)!
in thread CGI/HTML checkboxes to SQL query

Hi Mate, Thanks very much for your help. it is appreciated. As you can see I am a complete Perl beginner!!! I still have errors. When I ran the perl script with your changes I can get results back and it works great. However, when I put some form values in from the query string i.e http://localhost/cgi-bin/drive2.pl?Initiative=Initiative&ResOrientation=ResOrientation etc. What I don't understand is how to integrate these into the SQL statement based on what has been chosen. I get the
error message <!-- warning: DBD::ODBC::st execute failed: [Microsoft][ +ODBC Microsoft Access Driver] Too few parameters. Expected 1. (SQL­07 +001)(DBD: st_execute/SQLExecute err=­1)
Again many thanks.. Rachel.

Replies are listed 'Best First'.
Re: CGI/HTML checkboxes to SQL query
by rdfield (Priest) on Nov 26, 2002 at 11:35 UTC
    Looks like you have a placeholder in your SQL statement (a placeholder is a question mark - "?") and you're not supplying a value for it in your execute statement. There doesn't appear to be enough information in your posts for a fuller explaination - you should post all of the relevent information:
    • The actual SQL statement being executed
    • Any error messages generated by the DBI interface for your prepare and execute statements
    • Any parameters supplied to the execute statement.

    rdfield

      Okay this is an update on the problem. The good news is that I no longer get any errors. However, the script just goes ahead and executes the sql statement but without taking the form values into account. I will put this on my scratch pad, if anyone wants to take a look...... I would appreciate this. Thanks, Rachel
        It would be best to add the code on your scratchpad to the end of your previous node: for posterity, you know. Anyway, the problem seems to be with the HTML (as originally pointed out by theorbtwo in the CB): you have named all of your checkboxes "drive", so in order for your code to work you need something like (and this is untested):
        my %hash = (Initiative=>'DriveInitiative', ResOrientation => 'DriveResOrient', Creativity => 'DriveCreativity', ChangeOrientation => 'DriveChangeOrient', DecisionMaking => 'DriveDecisionMake', SelectLevel => 'ResLevel', ManagesPeople => 'ResManage'); my @checked = split /\0/,$cgi->param('drive'); my @clauses; foreach my $checkbox (@checked) { push @clauses, $hash{$checkbox} if validate($checkbox); }

        rdfield