CpHpristian Posted May 18, 2009 Share Posted May 18, 2009 I know that the problems with special characters have probably been discussed a thousand times.. but I couldn't find a satisfying solution yet. Whenever readout stuff from my database, it doesn't display German special characters like ö and ä and so on. The php-echos just work fine.. what can I do? Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/ Share on other sites More sharing options...
Daniel0 Posted May 18, 2009 Share Posted May 18, 2009 You need to make sure the correct character set is used throughout the entire process. This means in the database, in PHP and in the HTML. Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-836292 Share on other sites More sharing options...
CpHpristian Posted May 18, 2009 Author Share Posted May 18, 2009 I tried UTF8_general_ci for the collation and included <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> in my php-file.. but it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-836302 Share on other sites More sharing options...
CpHpristian Posted May 18, 2009 Author Share Posted May 18, 2009 What's interesting is that the special characters submitted by my HTML-forms look funny in the database but correct when readout. Hm. I need help here!! Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-836632 Share on other sites More sharing options...
thebadbad Posted May 18, 2009 Share Posted May 18, 2009 You'll also need to set the character set/names for the MySQL connection, like below, before you insert or retrieve anything: $connection = mysql_connect($db_host, $db_user, $db_pass) or die('Error connecting to database.'); mysql_select_db($db_name, $connection) or die('Error selecting database.'); mysql_query("SET NAMES 'utf8'", $connection); mysql_query('SET CHARACTER SET utf8', $connection); Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-836654 Share on other sites More sharing options...
CpHpristian Posted May 18, 2009 Author Share Posted May 18, 2009 It works! Thank you so much, thebadbad! Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-836674 Share on other sites More sharing options...
CpHpristian Posted June 3, 2009 Author Share Posted June 3, 2009 OK. So it worked on my computer at home.. .. but now it's getting mysterious. I transfered the same files to the XAMPP machine at school.. and the special characters were all garbled again. I tried everything - other than setting the browser to UTF-8 manually after every page click nothing helped. Then I created a php-file at school, using the same header. And the special characters were just fine. Then I opened two editor windows.. both had the exact same content (!!) but different file names.. in one window the characters were garbled and the other one was fine. ??? At home I used dreamweaver and at school the editor.. but after copy/pasting the content should have been just the same. I am so confused. Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-848551 Share on other sites More sharing options...
gevans Posted June 3, 2009 Share Posted June 3, 2009 Could be something as stupid as browser cache. Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-848555 Share on other sites More sharing options...
CpHpristian Posted June 4, 2009 Author Share Posted June 4, 2009 Both IE and Firefox are doing the same thing.. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-849072 Share on other sites More sharing options...
Daniel0 Posted June 4, 2009 Share Posted June 4, 2009 You need to make sure that the file itself is stored in UTF-8 (without BOM if your editor asks you). Quote Link to comment https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-849073 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.