PHP+MYSQL乱码问题
我的mysql编码是utf8_bin
页面的编码
用的是zend做开发,zend里面也都设置了PHP页面的编码utf-8
可是查询出来的数据到前台页面都是乱码。
我在连接数据库的PHP文件里加了一句mysql_query("set names 'gb2312'")执行后查询出来的数据可以正常显示了。就是前台页面调取数据库数据都是乱码。希望前辈们能给指点。
我的前台页面使用Dreamweaver写的
回复讨论(解决方案)
你的程序文件是什么编码的?
你的mysql库表及表中字段编码设置成utf8了吗
你的程序文件是什么编码的?
我在zend软件里面把PHP文件设置成了utf-8了。不知道是不是您说的程序文件的编码?
你的mysql库表及表中字段编码设置成utf8了吗
设置成了UTF8_bin编码了。后来我把数据库删了,又从新建了数据库,在建数据库时就设置成utf8_bin编码了,而且还看了表和字段的编码,都是utf8_bin啊
我后来把数据库删了,zend里面又重新建的项目,把页面里都设置成了utf-8.
我在连接数据库的文件里打印出数据,显示乱码。在连接数据库语句下面加了一句mysql_query("set names 'gb2312'"),打印出的数据都是中文了,但是从前台页面调取的数据。就又成乱码了
数据库删了,就表示数据库没有内容了。
那你怎么能查询到数据呢?
换句话说你是怎么把数据放入数据库的?
在连接数据库语句下面加了一句mysql_query("set names 'gb2312'"),打印出的数据都是中文了
表示你执行的程序文件是 gbk 编码的,而不是 utf-8 的
数据库删了,就表示数据库没有内容了。
那你怎么能查询到数据呢?
换句话说你是怎么把数据放入数据库的?
我是把数据库删了重新建的,数据是执行SQL语句重新加进去的。
在连接数据库语句下面加了一句mysql_query("set names 'gb2312'"),打印出的数据都是中文了
表示你执行的程序文件是 gbk 编码的,而不是 utf-8 的
那请问怎样修改程序文件的编码啊?不是在zend里面修改吗?
在连接数据库语句下面加了一句mysql_query("set names 'gb2312'"),我把gb2312改成utf8前台页面就可以正常显示中文了。我之前改成的是utf-8,前台页面显示的就是乱码。谢谢各位前辈的帮忙!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...
