Squarepusher Posted December 18, 2018 Share Posted December 18, 2018 (edited) No matter what I try, unicode characters that are read from a MySQL database like japanese ones are replaced by "?" while characters like "ä", "ö", "ü", "»", "«", etc. are replaced by "�". I pasted this at the top of the PHP code: header('Content-Type: text/html; charset=UTF-8'); mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8'); mb_regex_encoding('UTF-8'); I saved the PHP file as UTF-8 and UTF-8 without BOM and put <meta charset="UTF-8"> into it. (When I insert unicode characters directly in the file, they're displayed correctly, though...) I set the encoding in the phpMyAdmin database table to different "UTF-8" encodings. (They're displayed correctly too when viewed in the table directly...) Nothing worked so far. Any ideas? Edited December 18, 2018 by Squarepusher Link to comment Share on other sites More sharing options...
Ingolme Posted December 18, 2018 Share Posted December 18, 2018 Perhaps your database connection code needs to be set to use UTF-8. Link to comment Share on other sites More sharing options...
Squarepusher Posted December 19, 2018 Author Share Posted December 19, 2018 I set "collation connection", "collation server" and "collation database" to "utf8_general_ci" and "character set server", "character set results", "character set filesystem", "character set database", "character set connection" and "character set client" to "utf8" but it still doesn't help. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2018 Share Posted December 19, 2018 You do that in PHP after connecting to the database? Link to comment Share on other sites More sharing options...
Squarepusher Posted December 19, 2018 Author Share Posted December 19, 2018 No, I changed those variables in phpMyAdmin. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 19, 2018 Share Posted December 19, 2018 You need to change the actual connection, between your PHP script and MySQL. You do that in your PHP code. e.g.: $pdo = new PDO( "mysql:host=localhost;dbname=databasename", "user", "pass", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") ); Link to comment Share on other sites More sharing options...
Squarepusher Posted December 19, 2018 Author Share Posted December 19, 2018 Oh, I didn't know this. Thanks, it works now! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now