Your sample page looks correct, and the steps you take seem to cover most of the important points, there is one more thing that I would check. You wrote that the data is stored in the MySql database with UTF-8 encoding, but this does not necessarily mean that the PHP connection object also works with this encoding.
// tells the mysqli connection to deliver UTF-8 encoded strings. $db = new mysqli($dbHost, $dbUser, $dbPassword, $dbName); $db->set_charset('utf8'); // tells the pdo connection to deliver UTF-8 encoded strings. $dsn = "mysql:host=$dbHost;dbname=$dbName;charset=utf8"; $db = new PDO($dsn, $dbUser, $dbPassword);
The above examples show how to set the encoding for SQLI or PDO. Thus, the preparation of the connection object makes you independent of the database configuration, if necessary, the connection even converts the returned / sent data.
To check this on your page, make sure that the character set is installed before inserting / querying the database.
source share