将韩文字符插入mysql [英] insert korean characters to mysql

查看:117
本文介绍了将韩文字符插入mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MySQL中插入一些短语

I want to insert some phrases to MySQL

第一个字段是英语,第二个字段是韩语.每次我从PHP脚本中插入值时都会出现此问题,它在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. 학교

但是,如果我从PhpMyAdmin插入相同的韩文值,它将起作用,因此来自php脚本的问题.我在网上发现我必须在MySQL中更改Collation吗?

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?

有什么帮助吗?

<?

//*---------------------------------------------------------*\\
//* 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>

推荐答案

如Danack57所说,排序规则应设置为utf8_unicode_ci.

The collation should be set to utf8_unicode_ci as Danack57 says.

您应该只使用UTF8作为字符编码方案.

You should use just UTF8 as your character encoding scheme.

default-character-set = utf8

打开每个mysql连接后,执行set names utf8; 阅读

After opening each mysql connection, execute set names utf8; Read this

这篇关于将韩文字符插入mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆