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;".
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!