in reply to Re^3: Quoting Strings For SQL LIKE queries
in thread Quoting Strings For SQL LIKE queries
But there's still something I don't get.
If I use your code, and print $str after you've quoted it:
$str = $dbh->quote("%it's not a problem%"); print "<p>quoted: $str</p>";
I can see that it's been changed into '%it\'s not a problem%'
And it works.
But if I use that string literally, as in:
$sth = $dbh->prepare( "SELECT name FROM practice WHERE name LIKE '%it\'s not a problem%' " ) || die "Error: " . $dbh->errstr;
I get the error again.
And if instead I use this:
Then it works. Can you see the disconnect, and why I "deduced", wrongly it seems, that there are two different kinds of quoting?$sth = $dbh->prepare( "SELECT name FROM practice WHERE name LIKE '%it''s not a problem%' " ) || die "Error: " . $dbh->errstr;
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Quoting Strings For SQL LIKE queries
by jZed (Prior) on Dec 22, 2004 at 01:35 UTC | |
by Cody Pendant (Prior) on Dec 22, 2004 at 01:50 UTC |