Re: searching database on emailaddress field



On Tue, 31 Jan 2006 14:24:44 +1030, luke@xxxxxxxxxxxxxxx wrote:

Hi Luke

> Solved after I posted.
> Surround $email with 's.
> As in '$email'.

Nice try, but no cigar. See below.

>> my $sth = $dbh->prepare("select id, address from subs_email where
>> address=".$email); $sth->execute(); my @array = $sth->fetchrow;

my $sth = $dbh->prepare('select id, address from subs_email where
address=?');

$sth->execute($email);

This way, the value in $email is quoted correctly by DBI, so you don't need to
call $dbh -> quote() explicitly, which you were doing, right?


--
Ron Savage
ron@xxxxxxxxxxxxx
http://savage.net.au/index.html


.