4
我试图插入UTF-8字符串的细胞与utf8_general_ci
整理Mysql的插入编码问题
我的代码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
...
print mb_detect_encoding($name);
$query = "INSERT INTO items SET name='$name', type='$type'";
print $query;
mysql_set_charset('utf8'); // also doesn't help
$result0 = mysql_query("SET CHARACTER SET utf8") or die(mysql_error()); // I've added this line, but it doesn't solve the issue
$result01 = mysql_query('SET NAMES utf8') or die("set character ".mysql_error()); // still nothing
$result = mysql_query($query) or die(mysql_error());
我在HTML输出中看到什么:
UTF-8 INSERT INTO waypoints SET name='ČAS', type='ts'
我在数据库中看到的插入行为name
:
?AS
现在我的字符串是utf-8,我的表和单元格是utf-8 ..为什么编码错了?
你如何“看到它在数据库中”?也许这只是你工具的编码问题。 – Sirko
['mysql_set_charset()'](http://www.php.net/manual/en/function.mysql-set-charset.php)怎么样? – BlitZ
phpmyadmin ..无论如何,我试过选择和打印,它是stil?AS –