Guys, RE. My earlier checkbox question(s)! I have a minor problem with a SQL Query being run in Perl within IndigoPerl running on Win32 platform. The web server I am using is a local version of Apache. The SQL Statement is below: What I am trying to do is to feed each form value into the SQL statement from a posted form with checkboxes and drop down lists. My error message on the apache server is
Content-type: text/html <!-- warning: DBD::ODBC::db prepare failed: [Microsoft][ODBC Microsoft + Access Driver] Syntax error (missing operator) in query expression ' +ResourceSettings.ResID=Resources.ResID and () if ()'. (SQL­37000)(DBD: st_prepare/SQLPrepare err=­1) { +SELECT ResType, ResLevel, ResManage, Details, Length, Source, Cost, F +urtherDetails FROM ResourceSettings, Resources WHERE ResourceSettings.ResID=Resources.ResID and () if () ORDER BY ResType, ResLevel, ResManage, Details, Length, Source, Cost, FurtherDetails} at c:\I +NDIGO~1\CGI­BIN\DRIVE2.PL line 46. --> <H1>Software error:</H1> <PRE>No sth: ''No such file or directory at c:\INDIGO~1\CGI-BIN\DRIVE2 +.PL line 46. </PRE> <P> For help, please send mail to the webmaster (<a href="mailto:you@your. +address">you@your.address</a>), giving this error message and the time and date of the error.
my $hash ={ Initiative=>'DriveInitiative', ResOrientation => 'DriveResOrient', Creativity => 'DriveCreativity', ChangeOrientation => 'DriveChangeOrient', DecisionMaking => 'DriveDecisionMake', SelectLevel => 'ResLevel', ManagesPeople => 'ResManage'}; my @clauses = (); foreach my $checkbox (keys %$hash) { push @clauses, $hash->{$checkbox} if validate($cgi->param($chec +kbox)); } my $where_clause = join(' and ',map($_.= ' = "on"', @clauses)); my $sql = "SELECT ResType, ResLevel, ResManage, Details, Length, S +ource, Cost, FurtherDetails FROM ResourceSettings, Resources WHERE ResourceSettings.ResID=Resources.ResID and ($where_clause) if ($where_clause) ORDER BY ResType, ResLevel, ResManage, Details, Length, Source, Cost, FurtherDetails";
Any feedback would be greatly appreciated.

update (broquaint): title change (was RE. My earlier checkbox question(s)!)


In reply to CGI/HTML checkboxes to SQL query by Rachel

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.