PHPcode & lt; html & gt; & lt; head & gt; bookentryresult & lt;/head & gt; & lt; body & gt; & lt; h1 & gt; bookentryresult & php inserts garbled data into the database
PHP code
Book entry resultBook entry result
Query ($ query); if ($ result) {echo $ db-> affected_rows. "data is successfully input in this book. ";} Else {echo" data entry failed. ";}?>
I have used header () to convert the php page to UTF-8
Both the database and table are encoded in UTF-8.
------ Solution --------------------
Discussion
Mysql_query ('set names utf8'); it is not set to mysqli. it should be $ db-> query ('set names utf8 ');
Where did you see the inserted data garbled? Phpmyadmin?
------ Solution --------------------
I have encountered a normal program code, and the page shows normal, except for garbled characters in phpmyadmin. That's not the configuration of phpmyadmin, but I don't know how to change it. You can write a simple applet to read the database content to the page and view it.
------ Solution --------------------
Is there a problem with program code.
------ Solution --------------------
Execute mysql_connnet (…) first (......), After the database is linked, execute mysql_query ("set names UTF-8 ");