remove accent

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
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

remove accent

Post by yacahuma »

Hello,


I am creating a site in spanish. People are going to be searching stuff by person name. Some people may enter the name with accent and some dont. My idea was to create an extra field in the table to keep the not_accented name. At the time of the search just remove the accent and search againt the no accent column.

First, if you have a better idea, let me know.

The problem is that I dont seem to be able to remove the accent. I tried the functions in php.net for strtr but they dont seem to work. I always get the same input word.


my page have the content uf8 and mysql table is utf8


any ideas.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: remove accent

Post by Kieran Huggins »

You could try converting the charset to latin1 in MySQL (during the match, no need for a separate column):

Code: Select all

SELECT * FROM `sometable` WHERE CONVERT( _utf8 '$name' USING latin1 ) LIKE CONVERT( _utf8 `name` USING latin1 )
also, it should leave both your dataset and form untouched.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: remove accent

Post by yacahuma »

Hello, sorry it took so long , but I always get a syntax error when running that sql.
Post Reply