I would like to ask how to obtain data from the database on a simple UTF-8 page. Chinese characters are question marks, and no way can be used.

Source: Internet
Author: User
Ask how to obtain data from the database on a simple UTF-8 page. the Chinese characters are question marks, and the methods used cannot be HTMLcode & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDXHTML1.0TransitionalEN & quot; www. w3.orgTRxhtml1DTDxhtml1-transit ask how to obtain data from the database in a simple UTF-8 page. Chinese characters are question marks, and no way can be
HTML code
  
  Chinese garbled characters
  

Table 1



Now Table 1 in p can be normally displayed, that is, the Chinese characters of the data extracted from the database are changed to question marks, and English is also normal.

------ Solution --------------------
1. query ("set names 'utf8'") before the database retrieves data. Note that the database encoding must also be SET to UTF8.
2. file encoding in UTF-8 format
3. add in php

Header ('content-Type: text/html; charset = UTF-8 ');

Over. for short, the three codes are the same...

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.