$hex_string = unpack('H*', $output); $sth = $dbh->prepare("update Table1 set Image = 0x$hex_string where Id = 1"); ...