2

Possible Duplicate:
UTF-8 all the way through

So I saved some data in a mysql database and its stored there with "umlauts". When I'm speaking of umlauts I mean these German letters: ö, ä, ü and their capitalized pendants.

So now I execute a query via PHP, something like this:

$query = "SELECT * FROM tcms_references WHERE id =".$row->id;
$erg = mysql_query($query);
$rowt = mysql_fetch_object($erg);
foreach($row as $x) {
echo $x
}

Now, there is no German word like "Baumfällung" saved in my database. The PHP query is executed and presented on the screen as "Baumfällung".

My question: Where can I set UFT-8 as a Standart in PHP? Is there any function or something?

4

3 Answers 3

5

You need to set mysql connection to utf8

mysql_query ('SET NAMES UTF8;');
mysql_query ('SET COLLATION_CONNECTION=utf8_general_ci;');
mysql_client_encoding($conn);// where $conn is your connection

save page as utf8 and also put this in head of page

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
2
1

Try to set mysql table to utf8 or else use

 echo utf8_encode($x);
0

This might not be a PHP issue. You should check that the character collation used in your database matches the one you're using to gather these special character. If those don't match there is no way the DB can save the right value you request.

1
  • I already answered that. My database's charset is set to UTF-8. Dec 12, 2012 at 22:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.