


What should I do if the php link to sqlserver is garbled in Chinese?
Solution to the Chinese garbled code in php link sqlserver: 1. Open the query analyzer of sqlserver2005; 2. Open [php.ini] and configure [mssql.charset = "utf-8"]; 3. In php Add relevant codes to the file; 4. Transcode the input data.
Solution to Chinese garbled php link to sqlserver:
First, open the query analysis of sqlserver2005 Run the server , code
SELECT COLLATIONPROPERTY('Chinese_PRC_Stroke_CI_AI_KS_WS', 'CodePage')
, and check the result. "936" is displayed, indicating that the encoding of the database is GBK
. The attached table is as follows:
936 Simplified Chinese GBK
950 Traditional Chinese BIG5
437 United States/Canada English
932 Japanese
949 Korean 8
66 Russian
65001 unicode UFT-8
Second, open php.ini and configure it as follows
mssql.charset = "utf-8"
Remember to restart the server! ! ! ! ! ! !
Third, add the following code in the php file,
<?php …… header("content-Type: text/html; charset=utf-8"); ……?>
Fourth, transcode the input data
The data table test is as follows:
The variable submitted by the simulation is type = 'Unicom', and it is transcoded
$type = '联通';$type = (iconv('UTF-8','GBK',$type));
sql statement is as follows,
$result= mssql_query("select * from dbo.test where type = '$type' and name = 'TOM'", $conn);
Fifth, transcode the query results (the core code is as follows)
$res['type'] = iconv('GBK','UTF-8',$result['type']);echo $res['type'];
View the output:
China Unicom
it shows good.
Sixth, change the fifth code as follows:
$res['stname'] = urlencode(iconv('GBK','UTF-8',$row['stname']));
Then, encapsulate JSON and send it out
echo urldecode(json_encode($res));
Related Learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of What should I do if the php link to sqlserver is garbled in Chinese?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
