Summary - Fetching Chinese Text from Database to Web
This section provides a summary on how to fetch Chinese text from MySQL database and send it to a Web page through Apache.
Retrieving Chinese characters from MySQL database and display them on Web pages requires that:
- MySQL server must send back result set with Chinese text data in UTF-8 encoding.
MySQL server takes the encoding name, utf-8, from the session variable character_set_results.
- The PHP engine must deliver Chinese text data to the Web browser in UTF-8 encoding
with the PHP engine through the Web server.
- The Web browser must display page text in UTF-8 encoding.
The Web browser takes the encoding name, utf-8, from the Content-Type setting in the Web page HTML document.
In the PHP Web page script, we have to:
- Set one MySQL session control variable: character_set_results=utf8.
This is to tell MySQL server that result set must be sent back in UTF-8 encoding.
- Use a <meta> tag to set Content-Type = "text/html; charset=utf-8"
for the Web page HTML document. This is to tell the Web browser that display page content in UTF-8 encoding
and take form input text in UTF-8 encoding.
In addition to UTF-8, GBK and Big5 are also supported by MySQL server and Web browsers.
Last update: 2015.
Table of Contents
About This Book
PHP Installation on Windows Systems
Integrating PHP with Apache Web Server
charset="*" - Encodings on Chinese Web Pages
Chinese Characters in PHP String Literals
Multibyte String Functions in UTF-8 Encoding
Input Text Data from Web Forms
Input Chinese Text Data from Web Forms
MySQL - Installation on Windows
MySQL - Connecting PHP to Database
MySQL - Character Set and Encoding
MySQL - Sending Non-ASCII Text to MySQL
►Retrieving Chinese Text from Database to Web Pages
Steps and Application Components Involved
Fetching ASCII Text from Database to Web
Fetching Chinese Text from Database to Web
Fetching Chinese Text from Database to Web in UTF-8
Fetching Chinese Text from Database to Web in GBK
Fetching Chinese Text from Database to Web in Big5
►Summary - Fetching Chinese Text from Database to Web
Input Chinese Text Data to MySQL Database
PDF Printing Version