Summary of mysql garbled characters read by php
Php reads the summary of mysql garbled text. if you need it, refer to it.When php reads mysql, the character set is involved in the following aspects.1. specify the character set of the
I used to use a
SET NAMES utf8 statement to set the character set before each connection, but
mysqli there was a
mysqli_set_charset function to do this, and I thought it was exactly the same as my own, but it was found in its documentation note.
Php + mysql obtains records in the database (especially the efficient paging function ). MySQL (the best combination with PHP). php (as the current mainstream development language) to obtain records in the database, complete personal experience, for
For better development, in this project, I wrote a few useful tool classes, mainly focusing on database operations, paging, and Sessions. 1. database connection tool class [php] & lt ;? PhpclassDBUtil {private $ host = & quot; localhost & quot;
Both 1.php and HTML are utf-8
2.convention.php inside the ' default_charset ' and ' utf-8 ',
It's not 3.dbmysql.class.php $result [] = Auto_charset ($row, gb2312, UTF8)
Automatic conversion character set supports array conversion
function
There are two table temporary table temp_t, and the positive table table1, are MyISAM, respectively, there are about 28W records.
Cron periodically fetches some information from the network every minute and stores it to temp_t (frequent
Problem:
MYSQL displays normal Chinese characters on the command line terminal, but garbled characters are displayed in JSP calls!Display garbled characters with JSP query, with (new String (string. getBytes ("ISO-8859-1"), "gb2312") or show
PHP Chinese garbled charactersIt is one of the common problems in PHP development.
PHP Chinese garbled charactersYesOccurs on the web page. Some are generated during MySQL interaction and sometimes related to the operating system. The following is
Summary:
The first point: the six are all dried into utf8.
Mysql> show variables like "% char % ";
+ -------------------------- + --------------- +| Variable_name | value |+ -------------------------- + --------------- +| Character_set_client | utf8
Use mysqldump to export databases.
First, I met a database named mydb,
There are two tables, mytable and mytabletwo.
Both tables have data.
C: \ Program Files \ mysql \ MySQL Server 5.1 \ bin> mysqldump-uroot-proot-D mydb> C:/KUjiegou. SQL//
Mysql inserts a Chinese garbled php file and sets the webpage encoding to UTF-8.
Header ("Content-type: text/html; charset = utf-8 ");
Before the database is inserted, the encoding passed to the database is set to UTF-8.
$ This-> mysqli-> query
Why are the exported data in Chinese garbled characters and the following code is used to back up the database? why are the exported data in Chinese garbled characters ??
// Back up the database
Define ('in _ fdyu', true );
Require ('Des/config.
Author/Translator: ye Jinrong (Email:), Source: http://imysql.cnFor reprinting, please indicate the author/translator and the source, and cannot be used for commercial purposes. violators must investigate.
译者:叶金荣(Email:),来源:MySQL手册版本
brophp Framework Development Time Connection database read UTF8 garbled solution(2012-09-15 10:41:22)reproduced
Tags: talk about it php
Category: Building Station technology
brophp Framework Development Time
The last two days to do the project is always confused problem, this is not just the MySQL Chinese garbled problem solved, the following small set my solution to share to everyone for your reference, but also convenient for their own inspection.
I small rookie one, in order to self-learning and Exchange PHP (Jquery,linux,lamp,shell,javascript, Server) and a series of knowledge, small rookie created a group. People who wish to visit this blog can come in and exchange. Seek common development.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.