in reply to Re^2: Quoting Strings For SQL LIKE queries
in thread Quoting Strings For SQL LIKE queries
Note that I also changed $dbh->errstr to $sth->errstr for your execute, the error is in whatever handle you are using ($dbh for prepare, $sth for execute).$str = $dbh->quote("%it's not a problem%"); $sth = $dbh->prepare( "SELECT * FROM practice WHERE name LIKE $str" ) || die "Error: " . $dbh->errstr; $sth->execute() || die "Error: " . $sth->errstr; OR BETTER $str = "%it's not a problem%"; $sth = $dbh->prepare( "SELECT * FROM practice WHERE name LIKE ?" ) || die "Error: " . $dbh->errstr; $sth->execute($str) || die "Error: " . $sth->errstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Quoting Strings For SQL LIKE queries
by Cody Pendant (Prior) on Dec 22, 2004 at 01:27 UTC | |
by jZed (Prior) on Dec 22, 2004 at 01:35 UTC | |
by Cody Pendant (Prior) on Dec 22, 2004 at 01:50 UTC |