Querying a UTF-8 Database

Hi all.
Have a UTF-8 Database.
The data in PhpMyAdmin looks fine.

Where I query the database from PHP, I do no get back proper unicode.
The Website header has charset=utf-8, no problem.
When I hard code some Unicode text, it appears fine on the site.


while( $PhraseArray= mysql_fetch_array($QueryResult) ) {
$Phrase1=$PhraseArray[$SiteLanguage];
$Phrase2=$PhraseArray[$LanguageName];
//$Phrase2=“Wŏ xuéxí făyŭ”;

i.e. ‘Wŏ xuéxí făyŭ’ appears fine on the site.
However, when I use the value queried from the database, the unicode is garbled.

Any ideas?

David

Alright, the new UTF pages are working fine:

http://www.linguashop.com/en/basic-phrases-latvian.php

But now the old pages have gabled text:

http://www.linguashop.com/fr/

1
The DB connection is the same all over the site:
function ConnectDB()
{
$db = “ABC”;
$link = mysql_connect(“MNO.your-server.de”, “ABC”, “Password”);
mysql_set_charset(‘utf8’,$link);
mysql_select_db($db) or die(mysql_error());
}

2
The table causing the garbled text is UTF-8
ENGINE=MyISAM AUTO_INCREMENT=68 DEFAULT CHARSET=utf8

3
The HTML header states UFT8

<meta http-equiv=“Content-type” value=“text/html; charset=utf-8”>

=========
Any idea what could be causing the garbled letters?

David

ScallioXTX you’re a genius!

Thanks so much.

See the results here:

David

Use mysql_set_charset to indicate to PHP that all data is utf-8 encoded :slight_smile: