Jump to content

MySQL/PHP user input - detecting input that should be exactly similar but is spelled a little differently


xenonoverlord

Recommended Posts

Hello,

Does anyone know if there are any (php) scripts out there that can detect user imput into a MySQL database that is differs slightly.

Or how you can handle such a problem without having to resolve to going "manually" through the database entries.

E.g. a script that can detect that

- Traversée Mont Blanc
- Salbitschijen, West Face

is very similar to

- Traversee Mont Blanc
- West face Salbitschijen

And asks if 1 should be replaced by 2 or vice versa...

thx !

Tom
Link to comment
Share on other sites

MySQL has a phonetic matching function called SOUNDEX() that may help you.

You can use PHP to cycle through and use preg_replace (or similar) to switch out characters like your é and e, and then compare strings.

You could also use a spellchecking library against a dictionary to try to correct common typos/spelling errors, but that will take a bit more work.

Of course all these solutions are best used for GENERATING A REPORT, not making automatic changes. :)
Link to comment
Share on other sites

Well, for the first case, you'll have to actually search for both, since they're separate characters; for the second, if you search for each word separately, you'll be able to find both cases. You'd be surprised how useless SOUNDEX() is when the "typo" is near the beginning of the word (not surprisingly, I guess, since the "sound" is different).
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.