devslashneil has asked for the wisdom of the Perl Monks concerning the following question:
However this will always return 0 for all cases. When i remove and $row[1] == $mid it works fine, but i need the $email and $mid to be the same. I've tried changing "==" to "eq" but that doesn't work either.sub member_exists { my ($email,$mid) = @_; chomp ($email,$mid); my $db = "nMail"; my $sock = "/tmp/mysql.sock"; my $user = ""; my $pass = ''; my $dsn = "DBI:mysql:$db;mysql_socket=$sock"; my $mid = (); my $dbh = DBI->connect($dsn,$user,$pass); my $sth = $dbh->prepare("SELECT S_Email,MID FROM ML_Subscribers"); $sth->execute() || die "Error: Could not get mailing list data\n"; while (my @row = $sth->fetchrow_array) { if($row[0] eq $email and $row[1] == $mid){ return 1; } } $sth->finish(); $dbh->disconnect(); return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SQL - Subroutine always returning true
by gmax (Abbot) on Jul 11, 2003 at 07:17 UTC | |
by devslashneil (Friar) on Jul 11, 2003 at 07:32 UTC | |
by nite_man (Deacon) on Jul 11, 2003 at 11:58 UTC | |
|
Re: SQL - Subroutine always returning true
by nysus (Parson) on Jul 11, 2003 at 06:25 UTC | |
by nysus (Parson) on Jul 11, 2003 at 07:47 UTC | |
by devslashneil (Friar) on Jul 11, 2003 at 06:27 UTC | |
|
One more minor item to consider.
by htoug (Deacon) on Jul 11, 2003 at 08:28 UTC | |
|
Re: SQL - Subroutine always returning true
by devslashneil (Friar) on Jul 11, 2003 at 06:49 UTC |