php Solution to mssql Chinese garbled code: 1. Add the statement "SELECT COLLATIONPROPERTY('Chinese_PRC_90_CI_AI', 'CodePage')" to the php page; 2. Convert the character set of the query sql statement.
php mssql Chinese garbled characters
1 Garbled characters when querying output (SELECT)
Because MSSQL databases are generally encoded in GBK, you can add
header('Content-Type:text/html; charset=GBK');
to the php page. You can also use the following statement to view: Then set the character set according to the corresponding table.
SELECT COLLATIONPROPERTY('Chinese_PRC_90_CI_AI', 'CodePage')
Return value corresponding table:
936 简体中文GBK 950 繁体中文BIG5 437 美国/加拿大英语 932 日文 949 韩文 866 俄文 65001 unicode UFT-8
2 Garbled characters during insertion (INSERT)
Garbled characters during insertion, the character set of the query SQL statement must be Conversion
$insert = "Insert into peple(name,sex) VALUES(N'帅哥','male') "; $insert = iconv("utf-8", "gbk", $insert);
3 When updating (UPDATE)
Same as above, perform character set conversion for the update SQL statement.
The above is the detailed content of What to do if php mssql Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!