checklist
-
$sql->set_charset('utf8')
right after connect.
-
header('Content-Type: text/html; charset=utf-8');
before any output
There are 2 sides involved - server and client. Client means PHP script, not HTTP client. And server needs to know what encoding does client expect.
And you set only server side encoding, telling mysql in which encoding data have to be stored.
But there is also a client.
In fact, Mysql is great in recoding. As long as one encoding can be translated into other, Mysql can do it. For the different clients for example.
It is not too much demanded nowadays, but this feature exists. So, Mysql need to know which encoding is supported by client. For this very purpose set_charset()
function exists.