my $Select_areas = "SELECT DISTINCT Instance_name FROM Geo_definitions_normalised where Geo_category_class LIKE ".$Special_data_retrieval." ORDER BY Instance_name \;"; my $sth_Geo = $dbh->prepare($Select_areas) or die "Couldn't prepare query: ".$dbh->errstr; $sth_Geo->execute() or die "Couldn't execute query: ".$sth_Geo->errstr; my @Geo_areas = $sth_Geo->fetchrow_array; ## I think that the problem is here.