my $dbh = DBI->connect("$db_name","$db_user","$db_pass") || die "Database connection not made: $DBI::errstr"; my $sth = $dbh->prepare("SELECT * FROM gtchat_pm_in WHERE pm_to = '$nick' AND new = '1' ORDER BY date DESC"); $sth->execute(); my $count = $dbh->selectrow_array(q{SELECT COUNT(1) FROM gtchat_pm_in WHERE pm_to=? and new=1}, undef, $nick); my $output = $main->createInfoOutput('newmails',{mails => $count}); return [$output]; $sth->finish(); $dbh->disconnect(); }