What to do if php mssql Chinese garbled characters

藏色散人
Release: 2023-03-02 06:20:01
Original
2620 people have browsed it

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.

What to do if php mssql Chinese garbled characters

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');
Copy after login

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')
Copy after login

Return value corresponding table:

936 简体中文GBK 950 繁体中文BIG5 437 美国/加拿大英语 932 日文 949 韩文 866 俄文 65001 unicode UFT-8
Copy after login

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!