How to solve search problem with accented words

Asked

Viewed 290 times

0

I entered a table into my database using the command load and the fields with accentuation were correct, as for example Sofá Nápoli, but by changing any record that contains accent by my control panel the record sent to the bank looks like this Sofá Nápoli, my table is coded as utf8_general_ci. When I search my site by the term Sofá Nápoli the record is not displayed. The rescue of my variable when typed in the search field is like this:

$_SESSION['s'] = addslashes($_REQUEST['s']);
$pesquisa = $_SESSION['s'];
$pesquisa = (strtolower($pesquisa));

I couldn’t find a solution that worked

2 answers

2


Use the function html_entity_decode() before passing the name to the database query. The call will look like this:

$string = html_entity_decode($string, ENT_QUOTES, "utf-8");
  • Hello @Dherik, thanks for the help, I made the change but the search field now gets the term so "non poly sofa".

  • What happens when you use: $string = html_entity_decode($string, ENT_QUOTES, "ISO-8859-1");?

  • Similarly the text looks like this: sofã¡poli

  • Let’s simplify it then. What is the value of varTitle when it does: var varTitle = html_entity_decode("Sofá Nápoli");?

  • Hello @Dherik, now the text is correct: Poly Sofa

0

When you go to make the consultation in the bank turn the two into high/low cash.

Example:

Select * from where LOWER(campo) like LOWER($pesquisa)
  • Hi @Gerson Costa, thanks for the tip but it didn’t solve my problem.

Browser other questions tagged

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