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.