The data read from MYSQL is garbled. please help me. this is the first question post for the new year. thank you!

Source: Internet
Author: User
The data read from MYSQL is garbled. for help, please post the first question in the New Year. thank you! & Lt ;! DOCTYPE & nbsp; html & nbsp; PUBLIC & nbsp; "-// W3C // DTD & nbsp; XHTML & nbsp; 1.0 & nbsp; transitional // EN "& the data read from MYSQL is garbled. for help, please post the first question in the New Year. thank you!




Untitled Document





Header ("content-type: text/html; charset = utf-8 ");



$ Conn = mysql_connect ('localhost', 'root ','');
Mysql_select_db ('test ');
$ Xieru = "SELECT * FROM 'content '";
$ Result = mysql_query ($ xieru, $ conn );


For ($ count = 0; $ count <10; $ count ++)
{

Echo mysql_result ($ result, $ count, "people ")."
";

Echo"
";
}
?>


Such as the code above, read the data field PEOPLE from the table CONTENT, how the operation is garbled, the database is the UTF-8 code, ask for help,


------ Solution --------------------
What do you see in phpmyadmin?
I also need to post a picture.
------ Solution --------------------
Set the encoding before querying data.

mysql_select_db('test');
mysql_query("set names utf8");
$xieru="SELECT * FROM `content`";

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.