Home > Backend Development > PHP Problem > What to do if php insert into garbled characters

What to do if php insert into garbled characters

藏色散人
Release: 2023-03-03 09:40:02
Original
2395 people have browsed it

Solution to php insert into garbled characters: 1. Before connecting to the database, add "mysql_query("SET NAMES UTF8");"; 2. Add "content-type: text/html;" to the header of the html page. charset=UTF-8;".

What to do if php insert into garbled characters

php insert into garbled characters:

Before connecting to the database, mysql_query("SET NAMES UTF8") has been added;

HTML page header, add header("content-type:text/html; charset=UTF-8");

The encoding of all pages and files are unified. Think about the places where you can set the encoding. The meta in the html head also needs to be set. You can open the template file, or related html files, or php files, use editing software, and save it in utf8 format.

Recommended: "PHP Tutorial"

The above is the detailed content of What to do if php insert into garbled characters. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template