in reply to Re^8: DBI, place holders and CGI forms
in thread DBI, place holders and CGI forms

I don't see how this applies to inserts. Provide an example of what you are trying to do.

Replies are listed 'Best First'.
Re^10: DBI, place holders and CGI forms
by Anonymous Monk on Jun 20, 2011 at 08:35 UTC
    I have a got a HTML form. It has multiple fields. The data should be inserted into the database using DBI. I'd like to use placeholders in the query. They aren't all required fields. I was wondering if I could use your method for dynamically inserting values into the database, or should I just insert everything after initialising in the general form $fieldname = $cgi->param('fieldname') || null;?

      There is no null keyword in Perl.

      The value you're most likely thinking of is undef, and that's what $cgi->param(...) returns if no such field is found. So most likely, the below code already does what you might want:

      $fieldname = $cgi->param('fieldname')

      Note that the browser might send empty strings instead of missing values, depending on how your form is set up. But that's a different problem.

        sorry, I mixed up my perl and sql syntax.