Mysql turns #39; into #226;€™?(Mysql 把 变成了 ?)
问题描述
如何在插入时阻止 mysql 将 ' 转换为 '?
How can I stop mysql from converting ' into ’ when I do an insert?
我相信它与字符集或什么有关?
i believe it has something to do with charset or something?
我正在使用 php 执行 mysql_insert.
I am using php to do the mysql_insert.
推荐答案
您发布的单引号称为 '重音',它经常被一些 Web 应用程序从通用单引号转换而来.它是一个 UTF8 字符,当插入到 Latin-1 数据库中时,它会转换为 '’'.这意味着您需要将 MySQL 的字符集更改为 UTF8,或者将您网站的字符集更改为 Latin-1.前者将是首选:
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 把 ' 变成了 '?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Mysql 把 ' 变成了 '?
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
