What should I do if garbled characters appear when writing php to mysql?

王林
Release: 2023-03-04 19:02:01
Original
2441 people have browsed it

Solution to garbled characters when php writes to mysql: Just set the encoding before executing the [mysql_select_db()] statement, such as: [mysql_query("set names utf8")].

What should I do if garbled characters appear when writing php to mysql?

Problem restoration:

(Recommended tutorial:php graphic tutorial)

Restore the data When writing to the database, garbled characters appear as shown below:

What should I do if garbled characters appear when writing php to mysql?

Solution:

(Video tutorial recommendation:php video tutorial)

Add the following code before selecting the database

mysql_query("set names utf8");
Copy after login

What should I do if garbled characters appear when writing php to mysql?

Effect:

What should I do if garbled characters appear when writing php to mysql?

Problem solved!

The above is the detailed content of What should I do if garbled characters appear when writing php to mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
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!