MySQL Forums
Forum List  »  Newbie

quote , double quote escape
Posted by: Barrie Lees
Date: August 12, 2004 03:17PM

This is a php query where we are searching for the string 20" (20 inches) in the field named title.
The search string is stored in a php variable
The 20" is escaped, see next line
SELECT * from dbslide WHERE title LIKE "%20\"%"

It produces an SQL syntax error message.

I also tried escaping with the function, mysql_escape_string (after stripslashes)
which produces the next line

SELECT * from dbslide WHERE title LIKE \"%20\"%\"
It also produces an SQL syntax error message.

I can fix it by changing the first and last double quotes to single quotes BUT if I then search for a string containing a single quote I get the same error message.

I can also fix it by typing the inch symbol in TWICE at the form entry eg 20""
SELECT * from dbslide WHERE title LIKE \"%20\"\"%\"
This works.

Is this a bug in Mysql or am I missing something?

Options: ReplyQuote


Subject
Written By
Posted
quote , double quote escape
August 12, 2004 03:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.