I have a html form which – when posted – executes a SQL string in a Mysql db like this:
SELECT *
FROM IpProvider, IpUsers
WHERE IpProvider.UserId = IpUsers.Id AND
(IpProvider.CompanyName LIKE '%køb%' OR IpProvider.ShortDescrip LIKE '%køb%')
This returns 0 rows, but should return 1 row (as the danish word “køb” is part of the text in ShortDescrip). This search works fine with other text strings not holding danish characters.
The text directly copied from the table field:
"Køb kvalitet fra starten - det er vores råd."
Hmtl file holds a metatag stating: charset=utf-8
And the collation in the mysql table field is:
utf8_general_ci
Any ideas?
Try to issue this query:
SET NAMES utf8;at the beginning of your script. This will ensure that MySQL and your library “talk” UTF8 everywhere.Also, try to change the collation for
utf8_unicode_ci. This one is (supposedly) slower, although it handles better collations in some languages.[Edit] My second advice might be irrelevant, as after reading again your question, you said that the search string appears “as is” in your db. I tend to use utf8_unicode_ci by default, though.