in reply to DBI and like statment
It may be that $query contains some metacharacter that is causing problems. Using either $dbh->quote() or placeholders will avoid this problem: my $sql = "select title from $TABLE2 where astype like " . $dbh->quote("%$query"); I generally prefer using placeholders:
Note that, if you use a placeholder, the placeholder must substitute for the entire string being matched, including any wildcards.my $sql = "select title from $TABLE2 where astype like ?"; my $sth = $dbh->prepare($sql) or die "Cannot prepare: " . $dbh->errstr +(); $sth->execute("%$query") or die "Cannot execute: " . $sth->errstr();
P.S. $ and @ interpolate in double-quoted strings, but % does not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: DBI and like statment
by sixcolors (Initiate) on May 31, 2001 at 08:49 UTC |