2

I've got some issues with non-latin characters.

Query:

SELECT * FROM table WHERE name LIKE '%{$phrase}%'

PHP:

$phrase = $_POST['phrase'];
//$phrase = strtolower/strtoupper($_POST['phrase']) made no differece

Demo database:

Asomething (in the db stored as Asomething)
asomething (in the db stored as asomething)
Äsomething (in the db stored as Äsomething)
äsomething (in the db stored as äsomething) 

Either I type a or A, I get what I want - both of results, but... if I type Ä, I get only one result containing uppercase. How can I get both of them?

Edited: I use collation utf8_general_ci

Jurgen
  • 197
  • 1
  • 9
  • What is the collation setting? Did you want to try `mb_` functions in php? http://php.net/manual/en/function.mb-strtolower.php "Utf-8 All the way through"? – mickmackusa Mar 15 '19 at 08:30
  • What charset and collation are you using in your tables? You should set it all as UTF-8. – M. Eriksson Mar 15 '19 at 08:30
  • https://stackoverflow.com/q/279170/2943403 if the duplicate doesn't fix your issue, the page can be reopened. Now the responsibilty is yours to prove that you executed the advice all the way through. – mickmackusa Mar 15 '19 at 08:36

2 Answers2

1

Try using mb_strtolower($phrase , 'UTF-8');

Guga Nemsitsveridze
  • 721
  • 2
  • 7
  • 27
0

just lowercase your search query always.

SELECT * FROM table WHERE LOWER( name ) LIKE '%{$phrase}%'

https://stackoverflow.com/a/2876802/2693543

Shobi
  • 10,374
  • 6
  • 46
  • 82