PHP inserted database is garbled

Source: Internet
Author: User
PHP to get the post content of the HTML to the database, inserted after the display garbled, my database encoding has been set to UTF8, and then inserted before I echo out is not garbled, but into the database inside is garbled, do not know why, asked before I have searched, said to first execute

mysql_query ("SET NAMES ' uft8 '", $link);

In this way, I do so after the implementation and then refresh or the same, do not know how to solve, if a page resolved, if more than one page needs to insert into the data how to do it, please have experience to tell, thank you.


Reply to discussion (solution)

Did you set the encoding of your PHP page?

Header (' Content-type:text/html;charset=utf-8 ');

?>

Set up, my PHP page defaults to a new open automatically will be loaded into this sentence.

Yes, mysql_query ("SET NAMES ' uft8 '", $link);
UTF8 Best written UTF8

Is database determination also UTF-8 encoded? Right-click Database properties to see!

Look at the encoding of your editor

It's settled, thank you.

I also encountered garbled, seek to solve
mysql_select_db ("Set names UTF8");

Header (' Content-type:text/html;charset=utf-8 ');
Include "connect.php";

CREATE TABLE ' UserInfo ' (
' ID ' varchar (+) not NULL COMMENT ' primary key ID ',
' Truename ' varchar (+) DEFAULT NULL COMMENT ' name ',

PRIMARY KEY (' id ')
) Engine=myisam DEFAULT Charset=utf8;

So the place is set to UTF-8, or in garbled, novice just learn, ask the great God advice

  • 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.