$sql = "SELECT count(*) FROM table WHERE name = 'Jamie'"; $sth = $dbh->prepare( $sql ); if ( $sth && $sth->execute() ) { $row = $sth->fetchrow_arrayref(); print( "Returned " . $row->[0] . " row(s)\n" ); } else { print( "Error " . $dbh->errstr() . "\n" ); exit( 1 ); }