in reply to compare two values in perl
$usr is your statement handle object, not the value from the database. You need to fetch it. Further, it doesn't make a whole lot of sense to compare what you get from the database to $user_name, since you're selecting on that value anyway! Instead, I'd just check to see if the query returned anything:
If you want to get the actual value returned by the DB, you can use one of the many DBI methods for fetching results. This will put the value of the user_id column in $usr.my $sth = $dbh->prepare(q{SELECT user_id from user where user_id = ?}); $sth->execute( $user_name ); if( $sth->rows ) { # do something here }
my ( $usr ) = $sth->fetchrow_array;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: compare two values in perl
by Devanchya (Beadle) on Dec 10, 2006 at 04:40 UTC |