my $dbh = DBI->connect('DBI:mysql:xxxx', 'xxxxx', 'xxx') || die "ERROR: $DBI::errstr"; my $sth = $dbh->prepare('select * from user where name = "' . $username . '"'); $sth->execute; my $counter = 0; while(my @Rows = $sth->fetchrow_array()) { $counter++; }