in reply to Re: Quoting Strings For SQL LIKE queries
in thread Quoting Strings For SQL LIKE queries
or similar.SELECT * FROM foo WHERE bar LIKE '%it's not a problem%'
OK for an example of it not working? If I do this:
$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: " . $dbh->errstr;
I get an error:
Error: You have an error in your SQL syntax. Check the manual that cor +responds to your MySQL server version for the right syntax to use nea +r 'it\'s not a problem'%'' at line 1 at /foo/bar.cgi line 29.
What I'm saying is, the quote() function puts backslashes before my apostrophes. But that's not what I need if it's LIKE (something containing an apostrophe). What am I missing?
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Quoting Strings For SQL LIKE queries
by jZed (Prior) on Dec 22, 2004 at 01:07 UTC | |
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 | |
|
Re^3: Quoting Strings For SQL LIKE queries (have a cookie)
by tye (Sage) on Dec 22, 2004 at 06:32 UTC |