从php到mysql的特殊字符
我知道有很多几乎相同的问题,但我仍然没有找到我的问题的答案。 我想将“les Îles Açores”放入数据库中。但我得到:
les Îles Açores
我尝试使用:
SET Names 'ut8)
$mysqli->set_charset("utf8");
mysql_real_escape_string()
- < code>htmlentities (这里我
得到了 htmlentities
,但我想知道是否还有其他方法)
Code:
$name_fr = $_POST["name_fr"]; $name_nl = $_POST["name_nl"];
$arr_kollommen = array("NAME_FR","NAME_NL");
$arr_waardes = array($naam_nl,$naam_fr);
$obj_db->insert("landen",$arr_kollommen,$arr_waardes);
有人知道如何解决我的小问题吗? 非常感谢!
I know there have been a lot of almost the same questions, but I still didn't find the answer to my problem.
I want to place "les Îles Açores" into the db. But I get:
les Îles Açores
I tried usin:
SET Names 'ut8)
$mysqli->set_charset("utf8");
mysql_real_escape_string()
htmlentities
(Here Igot htmlentities
, but I want to know if there's another way)
Code:
$name_fr = $_POST["name_fr"]; $name_nl = $_POST["name_nl"];
$arr_kollommen = array("NAME_FR","NAME_NL");
$arr_waardes = array($naam_nl,$naam_fr);
$obj_db->insert("landen",$arr_kollommen,$arr_waardes);
Does someone has an idea how to solve my litle problem?
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
确保表使用正确的
CHARSET
,例如:Make sure the table uses the correct
CHARSET
, for example:尝试使用而不是编码到 utf_8 解码。
像这样:
Try using instead of encode to utf_8 decode.
like this:
我可以看到 2 个可能的原因:
1)您的数据库不具有 UTF-8 字段
2)当您从服务器读取数据时,您没有将连接设置为 utf-8。如果您在写入时必须将其设置为utf-8,那么在读取时也必须将其设置为utf-8。
使用 PHPMyAdmin 检查数据是否被破坏...如果是,则意味着您的 SET 名称“utf-8”不起作用...
2 possible reasons i can see:
1) Your database doesn't feature UTF-8 fields
2) When you read your data from the server, you are not setting the connection as utf-8. If you have to set it utf-8 when writting you also have to set it utf-8 when reading.
Check using PHPMyAdmin if the data is wrecked... If it is, then it means that your SET names'utf-8' is not working...
您是否将“UTF-8”参数传递到您的 htmlentities 中,并以这种方式进行 html_entity_decode ?
html_entity_decode($text,ENT_QUOTES,"UTF-8");
Do you pass the "UTF-8" parameter into your htmlentities, and html_entity_decode this way ?
html_entity_decode($text,ENT_QUOTES , "UTF-8");