[英]MySQL and encoding result of strange character
I have a problem with relationship between MySQL and importing data into particular table. 我与MySQL和将数据导入特定表之间的关系存在问题。 Whenever the form is requested, all data that have unicode chars into it is translated to other strange characters (question mark). 每当请求表单时,所有包含Unicode字符的数据都将转换为其他奇怪的字符(问号)。
What I have tried uptil now: 我现在尝试过的内容:
SET NAMES 'utf8'
查询SET NAMES 'utf8'
mysqli_set_charset()
(thanks for noticing HAL9k) 通过mysqli_set_charset()
查询(感谢注意HAL9k) header("Content-type: text/html; charset=utf-8");
还添加了: header("Content-type: text/html; charset=utf-8");
my.ini
and php.ini
to set default charset to UTF-8 尝试编辑my.ini
和php.ini
以将默认字符集设置为UTF-8 Letter transformation into DB: 将字母转换为DB:
č, ć
is translated into ?, ?
č, ć
转换成?, ?
(HTML & DB) (HTML和DB) ž
is translated into
(HTML, in database it's the real character 'ž' - not translated) ž
被翻译成
(HTML,在数据库中为真实字符'
未翻译) My meta: 我的中继:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Code (Pseudo): 代码(伪):
$con = mysqli_connect($host, $db_user, $db_pass, $db_name) or die("Error.");
// Spremanje rekorda preko UTF-8 karaktera
mysqli_query($con, "SET NAMES 'utf8'"); // ovo je bolji način :-)
$selekt = "UPDATE proizvodi SET ..
WHERE slug='...'";
Don't hate me for procedural style. 不要讨厌我的程序风格。 :-) Cheers and thank you. :-)干杯,谢谢。 Suggestions please. 请提出建议。
Please try this in your db/table structure 请在您的数据库/表结构中尝试
utf8_general_ci utf8_general_ci
if this not work please find your current character set the code is below 如果这不起作用,请找到您当前的字符集,代码如下
if (!mysqli_set_charset($link, "utf8")) { printf("Error loading character set utf8: %s\n", mysqli_error($link)); } else { printf("Current character set: %s\n", mysqli_character_set_name($link)); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.