I want to insert some phrases to MySQL
the first field is english and the second one is korean. the problem each time I insert the value from my PHP script it's shows in the MYSQL like this. 학교
However, if I insert the the same korean value from PhpMyAdmin it will works, so the problem from the php script. I've found in the web that I have to change the Collation
in MySQL?
Any help ?
<?
//*---------------------------------------------------------*\\
//* if POST
//*---------------------------------------------------------*\\
if($_POST['addphrase'])
{
$SQL = "INSERT INTO `sd_phrases` VALUES(NULL,?,?)";
$db = new db();
$db->execute($SQL,$_POST['english'],$_POST['korean']);
$box = new true_box();
$box->init('PLease Wait....','index.php?action=phrases');
die();
}
?>
<form method="post">
<center>
<table class="horz">
<tr><th colspan="2">Add a new Phrase</th></tr>
<tr><td>English Phrase</td><td><div align="left"><input type="text" size="80" name="english"></div>
</td></tr>
<tr><td>Korean Phrase</td><td><div align="left"><input type="text" size="80" name="korean"></div>
</td></tr>
<tr><td colspan="2"><input type="submit" value="Add" name="addphrase"></td></tr>
</table>
</center>
</form>
The collation should be set to utf8_unicode_ci
as Danack57 says.
You should use just UTF8 as your character encoding scheme.
default-character-set = utf8
After opening each mysql connection, execute set names utf8;
Read this
The problem is the way the html page is reporting the encoding to the users browser. I suspect one is reporting as utf8 and the other is reporting as some other encoding. So when the values got posted back from the browser, the are encoded differently. Php does not do the encoding, it more or less takes what the forms post to it. Load with pages and check the encoding in the web browseraan see if you can get the two page to report the same encoding using meta tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With