Hi Jason,

Of course somebody's isn't going to match somebody\'s. :-) somebody\'s
should match somebody\'s -- because it's really matching the "somebody"
part. If you're using 4+, you can use IN BOOLEAN MODE to match
somebody\'s exactly:

MATCH (col) AGAINST (' "somebody\\\'s" ' IN BOOLEAN MODE)

However, I get the feeling that you're not really wanting to match a
word that has a backslash in it. e.g. You're getting extra backslashes.
mysql_escape_string()/addslashes() *DOES NOT* store the backslashes in
the table -- it's not even *possible* since they're only escape
characters in the query. If you're getting any extra backslashes when
retrieving data, too many were added during insertion -- you ran
mysql_escape_string/addslashes too many times. This happens if PHP's
stupid magic_quotes_gpc is on and you don't check for that.

Your text should come out exactly the way it was intended. Never, ever
any need for stripslashes(), etc. if it was inserted correctly. :-)


Hope that helps.


Matt



----- Original Message -----
From: "Jason Ramsey"
Sent: Thursday, November 13, 2003 4:10 PM
Subject: Backslash and full text searches


> We make extensive use of full text searches, but have run into some
problems
> with backslashes.  If a word like "somebody's" is entered into our
database,
> we escape the string using "mysql_escapes_string" in php.  So,
> mysql_escape_string("somebody's") becomes "somebody\'s" when it is
saved in
> the database.  The problem is, we don't seem to be able to match
against
> this in the database.
>
> Let's say we saved "somebody's" in the data base.  The following will
match
> fine and pull up the results expected...
>
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ("somebody's")
>
> ... But if "somebody\'s" is stored in the database, there seems to be
no way
> to match the "\".  We've tried all of the following...
>
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ("somebody's")
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ('somebody's')
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ('"somebody's"')
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ("somebody\'s")
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ('somebody\'s')
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ("somebody\\\'s")
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ('somebody\\\'s')
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ('"somebody\'s"')
> SELECT * FROM Table WHERE MATCH (Field) AGAINST ('"somebody\\\'s"')
>
> ... Any ideas?


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to