0

I have a problem extracting data from my MYSQL UTF8mb4_general_ci database with PHP as some characters (linke the '€' symbol and emojis) are not echoed correctly in the browser.

Here is the situation:

  • the database is encoded in UTF8mb4_general_ci
  • the table is encoded in UTF8mb4_general_ci
  • the column is encoded in UTF8mb4_general_ci
  • the string extracted from the record has been written straight from phpmyadmin
  • mysqli encoding has been set to utf8mb4_general_ci

Here's the code:

mysqli_set_charset($db_connection,"utf8mb4_general_ci");
  • strange fact: PHP mb_detect_encoding($string_from_db) does not return any value
  • the PHP script is encoded in UTF8
  • the browser displays correctly the '€' symbol echoed from php

For example:

echo('€'); // displays € correctly
  • the browser does not display the '€' symbol echoed from the db

For example:

echo($db_value); //does not echo '€' but rather ?
  • there is a PHP header specifying the content type is text/html UTF8
  • the html is set to UTF8 through the meta charset tag

What am I missing?

I checked the other posts on stack overflow but they don't answer my question.

Luca Pennisi
  • 85
  • 10

0 Answers0