displaying Korean characters from mysql database
Posted: Thu Jul 23, 2009 6:10 pm
So, this isn't really a php question, but I'm hoping someone can help me. I'm trying to make a script that changes the language to korean with a variable. I have a table set up called translations with a row that has both the english and korean translations of a particular phrase. When I created the table I made korean_translation of Collation euckr_korean_ci and after I save the information, phpmyadmin displays the characters the way they should be. However, when I run the script below, my browser displays $translation1 wrong, where as it displays $suposedtobe correctly. The script below must be saved with notepad as UTF-8, neither will be displayed correctly if you save it as ACSII. Can anyone help me out. Any help would be appreciated. Thanks.
The script outputs :
???? ??
???? ??
Code: Select all
<?php
require('config.php');
$connection = mysql_connect(SQL_HOST, SQL_USER, SQL_PASS) or die('Could not connect to MySQL database. ' . mysql_error());
$db = mysql_select_db(SQL_DB,$connection);
$sql = "SELECT translation_id, translation_name, english_translation, korean_translation FROM translations WHERE translation_name='translation1'";
$result = mysql_query($sql) or die(mysql_error());
$data = mysql_fetch_array($result, MYSQL_ASSOC);
$language = 'korean';
if ($language == 'english') {
$translation1 = $data['english_translation'];
echo $translation1;
echo '<br>';
$suposedtobe = 'Hello World';
echo $suposedtobe;
}
else if ($language == 'korean') {
$translation1 = $data['korean_translation'];
echo $translation1;
echo '<br>';
$suposedtobe = '???? ??';
echo $suposedtobe;
}
?>
???? ??
???? ??