Note that there are some explanatory texts on larger screens.

plurals
  1. POUTF-8 problems with characters from MySQL database (e.g. é as é)
    primarykey
    data
    text
    <p>I know there are hundreds of questions about UTF-8 woes but I tried all the approaches I could find, none of them helped.</p> <p>The facts: I'm trying to read a string that contains a <strong>é</strong> from my MySQL database and display it on a PHP page. Actually, it does display as é (but the font does not recognize it as such and thus another default font is used). The troubles arose when I wanted to convert this string to a filename using PHP functions for string replacement. PHP does not recognize this as the é character at all.</p> <p>Here's a quick rundown of what I'm doing:</p> <p>1) The String is stored in a MySQL database. The MySQL server settings are: MySQL connection collation utf8_unicode_ci<br> MySQL charset: UTF-8 Unicode (utf8)<br> The database itself is set to collation utf8_unicode_ci (MyISAM storage engine, not changeable due to shared server)<br> The actual table is set to collcation utf8_unicode_ci (InnoDB storage engine) </p> <p>The é shows up correctly in phpMyAdmin. The data is inserted into the DB via a Java program but I have also tried this with manually entered data (entered in phpMyAdmin).</p> <p>2) The PHP default_charset is not set (NO VALUE), I'm on a shared server and placing a manual override php.ini did not seem to work. Using <code>ini_set("default_charset", 'utf-8');</code> works but has no effect on the problem I have.</p> <p>3) Before I run the actual select query I query <code>SET NAMES 'utf8'</code>. The query itself is irrelevant but for testing I chose a simple <code>SELECT title FROM items WHERE item_id = 1</code></p> <p>4) The PHP file itself is encoded UTF-8. I have set the correct charset for the html with <code>&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;</code></p> <p>5) To test the problem I used htmlentities on the returned string (Astérix), checking the source code it is converted to <code>Ast&amp;Atilde;&amp;copy;rix</code> which is not correct of course. Accordingly, the string shows up as <code>Astérix</code> in the browser.</p> <p>What possible reason could there be for this? To me it seems like I set everything that can be set to UTF-8.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload