PHP + MYSQL garbled problem my mysql code is utf8_bin
Page encoding
Zend is used for development, and the PHP page encoding UTF-8 is also set in zend.
However, the queried data is garbled on the front-end page.
After mysql_query ("set names 'gb2312 '") is executed in the PHP file connected to the database, the queried data is displayed normally. The front-end page is garbled to retrieve database data. I hope our predecessors can give some advice.
My front-end page is written in Dreamweaver
Reply to discussion (solution)
What encoding is your program file?
Is the field encoding in your mysql database and table set to utf8?
What encoding is your program file?
I set the php file to UTF-8 in zend software. Do you know the encoding of the program file?
Is the field encoding in your mysql database and table set to utf8?
It is set to UTF8_bin encoding. Later, I deleted the database and created a new database. when I was creating the database, I set it to utf8_bin encoding. I also read the table and Field Encoding, both of which are utf8_bin.
I deleted the database and re-built the project in zend, and set the page to UTF-8.
I printed the data in the file connecting to the database, and it showed garbled characters. Add mysql_query ("set names 'gb2312'") under the database connection statement. The printed data is in Chinese, but the data is retrieved from the front-end page. It becomes garbled again.
If the database is deleted, the database has no content.
How can you query data?
In other words, how do you put data into the database?
Add mysql_query ("set names 'gb2312'") under the database connection statement to print all the data in Chinese.
Indicates that the program file you run is gbk encoded, not UTF-8
If the database is deleted, the database has no content.
How can you query data?
In other words, how do you put data into the database?
I deleted the database and re-built it. The data was re-added by executing SQL statements.
Add mysql_query ("set names 'gb2312'") under the database connection statement to print all the data in Chinese.
Indicates that the program file you run is gbk encoded, not UTF-8
How can I modify the code of a program file? Isn't it modified in zend?
I added a mysql_query ("set names 'gb2312'") under the database connection statement. I changed gb2312 to utf8 and the front-end page would display Chinese characters normally. I previously changed to UTF-8, and the front-end page displays garbled characters. Thank you for your help!