in reply to Perl Mysql Null Recordset
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.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 }
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 |