Jump to content

Special characters


CpHpristian

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/158562-special-characters/
Share on other sites

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);

Link to comment
https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-836654
Share on other sites

  • 3 weeks later...

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.

Link to comment
https://forums.phpfreaks.com/topic/158562-special-characters/#findComment-848551
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.