When you're viewing the page "online", you're loading the page through HTTP; in addition to that, it's likely your script outputs HTML instead of plaintext (?). It's unclear.
Either way, HTTP adds 1 additional layer of text encoding into the mix (check the HTTP headers in your browsertools with F12 -> Network tab -> Refresh the page
). HTML adds another couple layers into the mix, mainly within the <head>
section. In both cases you want to see if any (text/character)encodings are mentioned, if it isn't UTF-8
(like your database), such as say UTF-16
or ISO-8859-1
, then that may be the root of your problem.
Another possibility is that you've treated the text in a non-multibyte fashion since it was retrieved from MySQL. PHP unfortunately still has quite a few functions like that. An example of that would be if you used substr()
instead of mb_substr()
. You could rule this possibility out by printing the string value directly after it was retrieved from the database (before doing any manipulation or concatenation or the like).
Another option may be that you're actually describing a font issue instead of an encoding issue. Different fonts support different segments of unicode, so that could be your problem as well. PHPMyAdmin may well be using a different font than your webpage.
A fourth option is related to the database connection (in php). Databases define the type of character encoding at multiple levels: every database selects a charset*, every table, every char/varchar/text field individually; but (more relevantly), each connection has its own encoding. in your mysqli_connect
/PDO::connect
-style function, you could have another characterset selected.
* = As you had already determined yourself aswell, the problem cannot be with the database itself.
A fifth option is, basically identical to the fourth: it is possible that your database server has the wrong charset defined as per-connection default. In such a situation it could be that phpmyadmin defines its own per-connection charset (and thus overrules the mysql default), but your own website doesn't manually select one and thus gets the bad default. This option seems the least likely, but it is technically possible.