in reply to Perl Mysql Null Recordset

If you search for a single column and your query is guaranteed to return at most one row, you can use selectrow_array to do everything at once:
my $sql = "SELECT username FROM users WHERE username = ?"; my $user = $dbh->selectrow_array( $sql,{},$Username_POST ); if( $user ) { die "User '$user' exists; } else { ... # user doesn't exist }
Note: I dropped the semicolon at the end of your SQL - you don't want that there. I also used placeholders, which is a better way to go in general.

Update Or, if you want the whole row:

my $sql = "SELECT username FROM users WHERE username = ?"; my @row = $dbh->selectrow_array( $sql,{},$Username_POST ); if( @row ) { die "User exists"; } else { ... # user doesn't exist }

Replies are listed 'Best First'.
Re^2: Perl Mysql Null Recordset
by JoeJaz (Monk) on Nov 16, 2004 at 22:18 UTC
    Wow, that's an interesting use of the selectrow_array function. I didn't know that you could have it just return one variable. Very neat. Thanks, Joe