PHP MYSQL FULLTEXT - Search problem with Apostrophe - ideas?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
idotcom
Forum Commoner
Posts: 69
Joined: Thu Mar 04, 2004 9:24 pm

PHP MYSQL FULLTEXT - Search problem with Apostrophe - ideas?

Post by idotcom »

Hi all


I have a search form that searches my database for the query string using mysql's match and boolean.

The problem I found is this:

Say I have a record: Micheal's Fine Foods

Well if I search for micheal OR micheal's OR micheals no results are found. Yet, if I search for micheals fine foods, it will show the row with every other row that has the words fine or foods.


Is there any way to overcome this? Without having to replace every apostrophe in the database?


Any input appreciated... I need to fix this.

Thank you in advance!
HomerTheDragoon
Forum Newbie
Posts: 21
Joined: Sat Jul 08, 2006 2:10 am

Post by HomerTheDragoon »

yah there is theres a near function or somthing like that... 1 sec let me go find it, ill edit in a second.


SELECT * FROM tablename WHERE fieldname LIKE '%$string%'
alright, if u have % before and not after, it will find anything with the string you have as long as its the last word. Or if u have a % after then it will onlt find stuff with the first word your string. If you have them on both sides, it will find it with the word anywhere.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

using MATCH and AGAINST typically requires more than one word in the search (full text searching). That's why you're not returning anything with just 'michael' etc.

searching for 'michael's fine foods' might return more than one row, but if you order it by relevance, the one you want will show up first so you could limit your query to only one result if that's what you're after.
Post Reply