Hello

You should first prepare your statement then execute it. Look at the DBI manual for how you can do that. Basically your code should look something like:

my @hdr = qw/title instructor inst_email active max_students description syllabus begin_date syll_name begin_time class_length/; my @val = map "?", @hdr; my @real_val = map{param($_)}@hdr; my $sql; { local $" = ','; $sql = "insert into class_info(@hdr) values (@val)"; } my $sth = $dbh->prepare($sql); $sth->execute(@real_val);
This is a much cleaner approach and you don't need to worry about escaping noise and escaping the binary attachment since you can include the variable holding the binary data (the blob) directly to the execute statement.

Add sanity checks and dies as you want. They were removed for readability.

Aziz,,,


In reply to Re: Re: DBI file input to blob by abstracts
in thread DBI file input to blob by amracel

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.