In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "PHP mysqli Chinese garbled code how to solve", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "PHP mysqli Chinese garbled how to solve" it!
PHP mysqli Chinese garbled solutions: 1, check and modify the html file coding; 2, modify the mysql database sorting rules to "utf8_general_ci"; 3, before the implementation of the SQL statement to add the setting code.
This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.
What about the Chinese garbled code in PHP mysqli?
Chinese garbled error of new data in PHP mysqli
First, the emergence of problems
When using PHP mysqli to connect to the database to write data, it is found that the Chinese written to the database is garbled, assuming that this is a coding problem.
II. The process of investigation
1. File structure
File name remarks addbook.html form submission data web page addbook.php php file for executing sql statements common.php stores configuration data such as mysql database host
two。 First of all, I checked the html file and made sure that I used the
3. Secondly, the mysql database is checked. The character set is utf8 and the sorting rule is utf8_general_ci.
4. Finally checked the PHP file, and finally found the problem.
Casually printed the Chinese data transmitted by the form and found that there was no garbled code.
So the remaining problem is that the code that connects to the database is not properly coded.
III. Solutions
Important: add setting encoding before executing the SQL statement
/ / set the encoding mysqli_query ($conn, "set names utf8"); / execute the sql statement $rs = mysqli_query ($conn,$sql); / / close the stream mysqli_close ($conn)
Never put mysqli_query ($conn, "set names utf8"); after the sql statement is executed, it will still be invalid.
Thank you for reading, the above is the content of "how to solve PHP mysqli Chinese garbled". After the study of this article, I believe you have a deeper understanding of how to solve this problem of PHP mysqli Chinese garbled, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.