How to include words without accent in search results - PHP, Mariadb

Asked

Viewed 60 times

1

Please, I need a little bit of your wisdom and patience.
I’m developing a website, which has a search page, and I need to make the results presented "Accent insensitives".
That is, if the person type "John", the result needs to appear, and if the person type "Joao", the result also needs to appear.
I understand that this is an old problem, with hundreds of posts on the Web, talking about it, with hundreds of proposed solutions.
The problem is that I’ve tried everything, and words without accentuation, do not appear in the results at all.
The site is in PHP and the database is original from Vestacp, Mariadb.
The database, has Charset UTF8, and collation utf8_unicode_ci.
I’ve changed the Charset to Latin1, and the collation to latin1.swedish.ci, already left as UTF8/utf8_general_ci, and with all the tables with the same charset and collation, but everything turned out the same.
All pages are with UTF-8, even I’ve been careful to redo PHP file, with UTF8 encoding.
And to my annoyance, the result is ALWAYS the same.
If I type with accent, the search returns OK, if I search without the accent, returns nothing.
It doesn’t matter if I use it when doing update utf8_encode($string), and then utf8_decode($string).
It doesn’t change anything because the words are correctly accented in the result.
That is, it is ONLY a problem of searching without sharp words.
Ahhh, I’ve tried using utf8mb4, and it didn’t work either.
I tried to use a "tiraacentos" function, despite being a provisional solution, but I could not, because the function would need to work also, in the database, and even trying to treat the result, which comes from the bank, I could not, because it features special characters and not accented letters.
Ex. "SÃ Paulo", you can’t replace it, because the function does not bring the "£" and several other special characters (still, it would be a horrible solution).
I already set up the connection, Name, everything as mysqli utf8, and nothing helped, no error but does not work.

mysqli_query("SET NAMES 'utf8'");
mysqli_query('SET character_set_connection=utf8');
mysqli_query('SET character_set_client=utf8');
mysqli_query('SET character_set_results=utf8');

It already includes callate, in its own search, and then worsens everything, because there is no result, nor with accented words

SELECT * FROM imoveis WHERE imovel_cidade LIKE _utf8 "%São Paulo%' COLLATE utf8_unicode_ci

I have tried to change the table Collate to utf8_unicode_ci_ai, and the database does not let.
Would someone please have some other tip, so I can try to implement and resolve this issue?
Thank you very much, any hint!
Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.