Home > Database > Mysql Tutorial > body text

php 操作 mysql 数据库 编码 错误

WBOY
Release: 2016-06-06 09:41:48
Original
1153 people have browsed it

编码mysqlphp数据库unicode

有两行相同的代码,来自不同的 php 文件,在对 MySql 数据库(UTF-8格式)操作时,一行代码正常,一行代码异常

代码1,异常
update ordersystem.product Set PName='333汽车' Where Bianhao='XAHNBQ2LC42GJQP-25';
在将这行代码保存到记事本时提示:需要保存为 Unicode 格式
代码来自文件 A.php,文件保存格式UTF-8,该文件是纯 php 文件,没有html代码,也没有编码转换;

代码2,正常
update ordersystem.product Set PName='222汽车' Where Bianhao='XAHNBQ2LC42GJQP-25';
在将这行代码保存到记事本时提示:直接保存为 ANSI 格式
代码来自文件 B.php,文件保存格式UTF-8,该文件同时有 html代码,并且有 meta http-equiv="Content-Type" content="text/html; charset=UTF-8" / 这一句

两行代码不同的地方在最后的编号 'XAHNBQ2LC42GJQP-25' 这个地方,其他地方是正常的

问题:
1,是什么原因导致第一段代码的是 Unicode 格式的?
2,有什么方法可以把第一段代码装换成能被数据库接受的格式?

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!