Mysql变成了“? [英] Mysql turns ' into ’?

查看:154
本文介绍了Mysql变成了“?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做插入操作时,如何停止mysql将'转换为 >

我相信它与字符集或东西有关系?



我使用php执行mysql_insert。

解决方案

您发布的单引号称为急性口音,通常由某些网络从通用单引号转换而来应用程序。它是一个 UTF8 字符,当插入到 Latin-1 数据库中时,转换为这意味着您需要将MySQL的字符集更改为 UTF8 ,或者将您的网站的字符集更改为 Latin-1 。前者是首选:

  ALTER DATABASE YourDatabase CHARACTER SET utf8; 
ALTER TABLE YourTableOne CONVERT TO CHARACTER SET utf8;
ALTER TABLE YourTableTwo CONVERT TO CHARACTER SET utf8;
...
ALTER TABLE YourTableN CONVERT TO CHARACTER SET utf8;


How can I stop mysql from converting ' into ’ when I do an insert?

i believe it has something to do with charset or something?

I am using php to do the mysql_insert.

解决方案

The single quotation mark you posted is called an 'acute accent', which is often converted from the generic single quotation mark by some web applications. It's a UTF8 character, which when inserted into a Latin-1 database translates to '’'. This means that you need to change MySQL's charset to UTF8, or alternatively change your website's charset to Latin-1. The former would be preferred:

ALTER DATABASE YourDatabase CHARACTER SET utf8;
ALTER TABLE YourTableOne CONVERT TO CHARACTER SET utf8;
ALTER TABLE YourTableTwo CONVERT TO CHARACTER SET utf8;
...
ALTER TABLE YourTableN CONVERT TO CHARACTER SET utf8;

这篇关于Mysql变成了“?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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