TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-09-2009, 07:34 AM   #1 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default Spell Check / Words similar to word - MYSQL

Hi all,
I am having a few issues, when a user does a search, my database sql is not searching for words that might be misspelt for e,g, In my DB someone has spelt development this way developement is there away that when a user searches for development it show both development and developement.

I need to make this to be the case for all words and if they misspell a word in search it needs to offer them the correction.

Thanks
russellharrower is offline  
Reply With Quote
Old 08-09-2009, 10:32 AM   #2 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Default

Yes there is, it is known as soundex.

MySQL has a built in function to do it http://dev.mysql.com/doc/refman/5.0/...nction_soundex
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
The Following User Says Thank You to JaoudeStudios For This Useful Post:
russellharrower (08-10-2009)
Old 08-09-2009, 11:26 AM   #3 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default

If you don't mind can you show me an example, of how you would use this in a MySQL
Code:
$sql = "SELECT * FROM sh WHERE sitename LIKE '%".$quary."%' OR keywords LIKE '%".$quary."%' OR title LIKE '%".$quary."%' OR body LIKE '%".$quary."%' OR writtenby LIKE '%".$quary."%' ORDER BY datetime DESC LIMIT $start, $limit";
russellharrower is offline  
Reply With Quote
Old 08-10-2009, 06:53 AM   #4 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Default

Just like in the example on the MySQL link I posted above...

$sql = "SELECT * FROM sh WHERE SOUNDEX(sitename) = '". SOUNDEX( $quary)."'";

NB: You should protect your query from mysql injection
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
The Following User Says Thank You to JaoudeStudios For This Useful Post:
russellharrower (08-10-2009)
Old 08-10-2009, 12:27 PM   #5 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default

Thank you, after adding a bit more code, it worked great.
Just wondering if you would be able to let me know, is there away to show the correct spelling to the user?

just like Google and Microsoft does?
russellharrower is offline  
Reply With Quote
Old 08-10-2009, 12:43 PM   #6 (permalink)
The Acquainted
 
JaoudeStudios's Avatar
 
Join Date: Jul 2009
Location: Surrey
Posts: 105
Thanks: 1
JaoudeStudios is on a distinguished road
Default

Yep.

But you would need a database of all the english words. I think there is one on the net floating around which is only a few megs (ish).
__________________
JaoudeStudios.com | JaoudeStudios.com Forum | JaoudeStudios.com Blog
OpenSource is the road ahead...!
JaoudeStudios is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
check rental item availability PHP MySQL drolex Advanced PHP Programming 1 07-15-2009 09:30 AM


All times are GMT. The time now is 06:27 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design