I have a php/mysql-application on a plesk-server with Apache and nginx. I have the strange problem that only when the browser is opened and the website is accessed for the first time in that browser-session, Umlaute (special characters) like the german ä ö ü are displayed as "?". As soon as I refresh the site, it won't happen again until I close and re-open the browser.
Everything from DB over PHP to HTML is UTF-8 encoded.
Any hints what I should look for?
I noticed that when deleting the cookies, closing and opening the browser, it does NOT happen.
I noticed the problems only happen with content coming from the (entirely UTF-8-encoded) MySql-DB and only when I'm logged in... very strange!
Solution
Ok, I'm not the person that silently goes away when I was just too dump to find my fault! So, hopefully my error will help someone else in the future:
I had a PDO-connection that only happens when a user was logged in, but his session timed out. This query logs the user in based on a cookie. On that SQL-connection, I had only:
$db = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
instead of
$db = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
As it seems, this was the whole error!