Something tells me you don't use warnings either. ("if ($data1 ne $digest1)" would warn if fetchrow_array returned zero rows.) Use use warnings;!