Home >Backend Development >PHP Tutorial >Collection of solutions to Mysql and web page display garbled code_PHP tutorial

Collection of solutions to Mysql and web page display garbled code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:53:04834browse

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318800.htmlTechArticleInsert data into php?name=%CA%FD%BE%DD%BF%E2"onclick=" tagshow(event)"class="t_tag" database displays garbled characters and data from php?name=%CA%FD%BE%DD%BF%E2"onclick="tagshow(event)"class="t_t...
Statement:
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