If the frame is inserted in Chinese and the view is not garbled if the Chinese is inserted and queried with PDO will not be garbled but the frame view PDO inserted Chinese will be garbled Using the PDO output to see the TP inserted in Chinese will also be garbled why is this? If you insert Chinese words directly in the MySQL black window Use the frame to see the Chinese is not garbled with PDO will be garbled my PDO added this sentence also don't use Ah header (' Content-type : Text/html;charset=utf-8; ');
I changed character encoding was blind later I looked at the character encoding of the table Discover why the field is UFT8 format table is GBK format? Like this situation how to let the framework and PDO way query Chinese talent is not garbled? Does the encoding of a field have anything to do with the encoding of the table? Which one is the most accurate?
This is the current character encoding for MySQL
CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `age` int(15) NOT NULL, `class` varchar(400) CHARACTER SET utf8 DEFAULT NULL, `name` varchar(12) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=390 DEFAULT CHARSET=gbk |
Reply content:
If the frame is inserted in Chinese and the view is not garbled if the Chinese is inserted and queried with PDO will not be garbled but the frame view PDO inserted Chinese will be garbled Using the PDO output to see the TP inserted in Chinese will also be garbled why is this? If you insert Chinese words directly in the MySQL black window Use the frame to see the Chinese is not garbled with PDO will be garbled my PDO added this sentence also don't use Ah header (' Content-type : Text/html;charset=utf-8; ');
I changed character encoding was blind later I looked at the character encoding of the table Discover why the field is UFT8 format table is GBK format? Like this situation how to let the framework and PDO way query Chinese talent is not garbled? Does the encoding of a field have anything to do with the encoding of the table? Which one is the most accurate?
This is the current character encoding for MySQL
CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `age` int(15) NOT NULL, `class` varchar(400) CHARACTER SET utf8 DEFAULT NULL, `name` varchar(12) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=390 DEFAULT CHARSET=gbk |
The TP framework uses the UTF8 format, so you must be the database character set is also a problem, you need to set the database to UTF8, the table needs to be set to UTF8 can be
You see the SQL code above, the field is UTF8, the table is GBK, there must be a problem
CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `age` int(15) NOT NULL, `class` varchar(400) CHARACTER SET utf8 DEFAULT NULL, `name` varchar(12) CHARACTER SET utf8 DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=390 DEFAULT CHARSET=utf8 |
ALTER DATABASE 数据库名 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
Do not tangle, unified the entire project involved in the coding of the place are set to UTF8 will not appear garbled problem