PHP inserts a database with garbled characters. PHP obtains the html post content to the database. after the database is inserted, garbled characters are displayed. the database encoding has been set to UTF8. before the insertion, I ECHO it and it is not garbled, but it turns into garbled characters in the database. I don't know why. I have already searched for it, and I want to execute it first.
Mysql_query ("set names 'uft8'", $ link );
In this way, I will refresh the page after this execution. I don't know how to solve it. if one page is fixed, what should I do if multiple pages need to be inserted into data, thank you for your experience.
Reply to discussion (solution)
Have you set the php page encoding?
Header ('content-Type: text/html; charset = utf-8 ');
?>
Set. by default, this sentence is automatically loaded when a new PHP page is created.
By the way, mysql_query ("set names 'uft8'", $ link); here
Utf8 is best written as UTF8
Is the database determined to be UTF-8 encoded? Right-click the database property to see it!
See the encoding of your editor
Solved. thank you.
I also encountered garbled code. please solve it.
Mysql_select_db ("set names utf8 ");
Header ('content-Type: text/html; charset = utf-8 ');
Include "connect. php ";
Create table 'userinfo '(
'Id' varchar (32) not null comment 'primary key ID ',
'Truename' varchar (100) default null comment' name ',
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8;
So the places are set to UTF-8, or garbled, novice just learn, please great God advice