troubleshooting Question

Problem with Perl - How to get image from sql database wrote to an external file?

Avatar of linbayzak
linbayzakFlag for United States of America asked on
11 Comments1 Solution720 ViewsLast Modified:
I've been trying to pull some binary data from a database and output this information into an image file (of any kind viewable in IE) but I'm running into some problems. For starters, I get this error in the STDERR Log: error_handler: Data-conversion resulted in overflow. I get this simply from selecting the image from the database, without even trying to display results. I am trying to display the image using the code attached. The CheckNum displays properly but I do not get an image in my link as I wish to achieve. Any ideas on what I'm doing wrong? Thanks.
my $DB21 = modules::Db->ConnectCheck21();
  my $sql = "SELECT Img, CheckNum
             FROM Image_View
             WHERE UserID = '$FORM->{StoreNum}'
             AND Acct = '$FORM->{BankAcctNum}'
             AND Routing = '$FORM->{RoutingNum}'
             AND CheckNum = '$FORM->{CheckNum}'
             AND Amt = '$FORM->{Amt}'";
  my $rs = $DB21->SelectHash($sql);
  <table border=0 width=35%>
    <td><b>Check 21 Image Link</b></td>
  my $bgcolor;
  my $background;
  my $num = 0;
  foreach(sort{$rs->{$a}->{CheckNum} cmp $rs->{$b}->{CheckNum}}keys(%$rs)){
    if($bgcolor == 1){
      $bgcolor = 0;
    }elsif($bgcolor == 0){
      $bgcolor = 1;
    if ($bgcolor == 1) {
        $background = "lightgrey";
    }else {
        $background = "#FFFFFF";
    open OUTPUT, ">output" . $num . ".png";
    my $newdata = $rs->{$_}->{Img};
    print OUTPUT $newdata;
    close OUTPUT;
    print "<tr><td bgcolor='$background'><a href='output" . $num . ".png' target='_blank'>$rs->{$_}->{CheckNum}</a></td></tr>";
Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros