in reply to Re: DBI file input to blob
in thread DBI file input to blob

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,,,