Reputation: 683
i am trying to add accent management in my request using the collation command, but i'am getting errors linked to invalid collation...
this is my sql request :
SELECT p.ID,p.NOM,p1.ID,p1.NOM,p.ISNAV,p.LIEN
FROM p
LEFT OUTER JOIN p AS p1 ON p.FK = p1.ID
WHERE ( p.NOM LIKE '%dev%' collate utf8mb4_unicode_ci
OR p.HTML LIKE '%dev%' collate utf8mb4_unicode_ci
OR p1.NOM LIKE '%dev%' collate utf8mb4_unicode_ci
OR p1.HTML LIKE '%dev%' collate utf8mb4_unicode_ci
)
and p1.TPL<>'search'
ORDER BY p.FK t
this is my error in php:
COLLATION 'utf8mb4_unicode_ci' is not valid for CHARACTER SET 'latin1'
this is my error in mysql command line:
COLLATION 'utf8mb4_unicode_ci' is not valid for CHARACTER SET 'utf8'
this request works in phpmyadmin
when i change utf8mb4_unicode_ci by utf8_unicode_ci in mysql console, the request works...but not in my php code.
i'am a bit lost, may someone explain me why i get collation error when my column seems to have the good collation.
Thanks
Upvotes: 0
Views: 601
Reputation: 5157
You could use the mysqli::set_charset
in php.
$mysqli->set_charset("utf8");
Upvotes: 1