3-character-long php search engine problem

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
luchosoto
Forum Newbie
Posts: 2
Joined: Mon Aug 15, 2005 7:26 pm

3-character-long php search engine problem

Post by luchosoto »

Hi everyone, I'm new to this forum and I hope there'll be someone out there who can help me out with this one.

Sometime ago I created a simple php search engine that searches for keywords in a MySQL database. (I'm using the MATCH - AGAINST method, and I don't wanna use the older method). Everything was doing fine until I had to move to another server. The problem now is that my search engine only searches for keywords longer than 3 characters. I wanna search for "dvd", for example, and my script finds nothing, but when I was in the previous server, it did.

I can't seem to find a solution for this problem and every solution I've tried has been to no avail. I'm pretty sure this has something to do with the server. :oops:

Can anyone help me out there?
Thanks beforehand.

ps: I've attached the sql query of my script.

Code: Select all

$results = mysql_query("SELECT * FROM Items WHERE MATCH (ItemName,ItemDescription) AGAINST ('$q' IN BOOLEAN MODE) LIMIT $page, $limit");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

luchosoto
Forum Newbie
Posts: 2
Joined: Mon Aug 15, 2005 7:26 pm

Post by luchosoto »

Uhmm, that seems to be the problem, thanks a lot, but Where can I find that line??

[mysqld]
ft_min_word_len=3

Is it in a file?
And what if that line is in a file I have no access to? b/c I've asked for help from the server administrators themselves, but they told me to locate a php.ini file within the same directory as my script...actually I didn't know what to do with the file, it was endless!

It also says I have to reset the server?? ohh no can do I guess...

isn't there any way to override the "ft_min_word_len" line??

I would appreciate any suggestions, solutions or workarounds.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it is a server start up option. There is no way of dynamically changing the setting.

you may be able to use a simple word breaking to isolate any orphan three letter words in a search request and use the LIKE or REGEXP keywords. That may be the easiest solution.. although you could technically roll your own fulltext search system too..
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

I go through the search terms and report back to the user if they've entered anything that's not going to return a result (short words, stop words, very long phrase searchs). So long as the user is kept informed they'll not have a problem with things not searching well.

That said, I also do a LIKE search if the user has only entered a short word.
Post Reply