my $dbh = DBI->connect("$db_name","$db_user","$db_pass") || die "Database connection not made: $DBI::errstr"; my $sth = $dbh->prepare("SELECT * FROM pm_in WHERE pm_to = '$nick' AND new = '1' ORDER BY date DESC"); $sth->execute(); my @entries=(); my $count=0; while(@entries=$sth->fetchrow_array) { $count++; } my $output = $main->createInfoOutput('newmails',{mails => $sth}); return [$output]; $sth->finish(); $dbh->disconnect();