Home >Backend Development >PHP Tutorial >Collection of solutions to Mysql and web page display garbled code_PHP tutorial
When inserting data into php?name=%CA%FD%BE%DD%BF%E2" onclick="tagshow(event)" class="t_tag">when the database is displayed, garbled characters and data are displayed from php?name=%CA% FD%BE%DD%BF%E2" onclick="tagshow(event)" class="t_tag">The problem that the data read from the database is displayed as garbled characters on the web page is actually to achieve php?name=%CA %FD%BE%DD%BF%E2" onclick="tagshow(event)" class="t_tag">The database encoding, web page encoding and table encoding are consistent)! The same applies to GBK2312
( 1) Set the database encoding. In order to be in line with international standards, it is generally set to utf-8
(2) The data table setting is also set to utf-8
(3) Set your web page encoding to utf -8, open Dreamweaver, (modify) -- (page properties)
(4) Add header("Content-Type: text/html; charset=utf-8") to the first line of your PHP file ;
(5) Before operating on the data, you should first perform the mysql_query('set names utf8'); operation, and then perform the query, update, insert, etc. on the data.