MySQL Escape Characters I'm getting an SQL error when trying to mix a match against in a SQL statement with a specific character which is not covered by MySQL escape functions in PHP. 

This is an example:

The name to search is: Tommy -

The generated (error) query is:

Select * 
From users
Where match(name,username) 
            Against('+tommy -*' in boolean     
                          mode)


What is the best way to fix it, and why the mysql_escape functions don't cover it?
MATCH(...) AGAINST('+tommy' IN ...)
    AND ... LIKE '%tommy -%'


That is, use FULLTEXT to do what it does best (search for words), then check the results against something more complex via LIKE or REGEXP.

Granted, it will take some intelligence in your app code to construct the suitable combination of MATCH and [R]LIKE.  But the result is fast and cover a lot more than FULLTEXT can do by itself.

Note:  The optimizer will do the MATCH first, then filter on the other stuff.