Why am I getting diamonds with ? for German chars?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

I have upgraded to XAMPP Control Pane v3.2.1, and now all sites that have words such as " Zubehör ", the ö is getting that character up. But it doesn't show LIVE, nor did it show on m prev version of XAMPP.

Any help?

Simon
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why am I getting diamonds with ? for German chars?

Post by requinix »

It probably means the old word was using the ISO 8859-1 encoding ("latin1") while the new XAMPP is using UTF-8.

Were there any sorts of upgrade scripts you needed to run? Where are these words coming from?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

The words are entered both manually and via DB.
Do I need to alter XAMPP?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why am I getting diamonds with ? for German chars?

Post by requinix »

What versions of PHP did you upgrade from and to? And what does

Code: Select all

SHOW CREATE TABLE whatever_database_table_those_words_are_coming_from
output? And what's your code to connect to the database?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

The code to connect to the database remains unchanged, and using PDO.
I'm not sure what version of PHP I was on.But I am now on:
PHP Version 5.6.8
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

[text]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">[/text]
This is what's at the top. Maybe that is wrong?
It works Live, and on the previous PHP version.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why am I getting diamonds with ? for German chars?

Post by requinix »

PHP 5.6 changed the default encoding for some things to UTF-8. You should be using that. However until you can change your code to do that, find the default_encoding INI setting and set that to iso-8859-1. And restart.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

Where do you find that code? I searched for that term in php.ini. not in there.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Why am I getting diamonds with ? for German chars?

Post by requinix »

Oh, I had the wrong name for it. How about you look through the php.ini for a setting that looks appropriate?
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Re: Why am I getting diamonds with ? for German chars?

Post by hybris »

Dunno if this helps but im using

Code: Select all

if (!$mysqli->set_charset("utf8")) { //can put error handling here}
(had the same problem with Swedish chars after an update. Above code fixed it for me anyway....
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

Thanks. What do you mean "can put error handing here"?
Do I literally wrap this code around the whole template??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Why am I getting diamonds with ? for German chars?

Post by Celauran »

Did requinix' suggestion not work?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

I would not know what "setting" to look for.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Re: Why am I getting diamonds with ? for German chars?

Post by hybris »

Code: Select all

    if (!$mysqli->set_charset("utf8")) {              // Har gor jag sa man kan skriva åäö i databasen.
    printf("Error loading character set utf8: %s\n", $mysqli->error);
    $SidText=$SidText."Vi har inte lyckats upprätta en UTF8 (Svenskt teckenuppsättning) anslutning med servern.\n";
    printf(" Error loading character set utf8: %s\n", $mysqli->error);
//} else {
    printf("Current character set: %s\n", $mysqli->character_set_name());
    $SidText=$SidText."Servern är mottaglig för UTF8 (Svensk teckenuppsättning) textformat.\n";
    printf("Current character set: %s\n", $mysqli->character_set_name());
}
I usually put it right before my first db call.. (You need it for both writing to or reading from the db)

Hope it helps.. I got really tired of those wierd signs to replace åäö :)
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Why am I getting diamonds with ? for German chars?

Post by simonmlewis »

I'm also getting them for € and $ and £.
All because I have the latest version of xampp. Maybe I should uninstall it and reinstall!

Would that uninstall all my sql databases?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply