All the problems found during php connection to mssql are problems. I have learned from my experience that this problem is a coding problem. I will summarize the solutions below. method 1: modify php. the INI file, of course, can be UTF-8 encoded based on your page ,... all the problems found during php connection to mssql are problems. I have learned from my experience that this problem is a coding problem. I will summarize the solutions below.
Method 1: modify the php. ini file. of course, you can set it to UTF-8 based on your page. the code is as follows:
; Mssql. charset = "ISO-8859-1"
Mssql. charset = "GBK"
Method 2: convert data directly in the program. The code is as follows:
Iconv ('gb2312', 'utf-8', $ data)
Method 3: use Ado Connection to set encoding during connection. the code is as follows:
$ Conn = new COM ("ADODB. Connection", NULL, CP_UTF8) or die ("Cannot start ADO ");
PHP example, the code is as follows:
"); // Printaline (" PLEASE? "); // Print (" This will not be displayed due to the above error. ");?>
Open ("Provider = Microsoft. jet. OLEDB.4.0; Data Source = $ db "); // $ conn-> Open (" DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ = $ db "); $ conn-> Open (" Driver = {SQL Server}; Server = {192.168.22.40}; Database = sugarcrm_db; UID = sa; PWD = 123456; "); // Execute the query and output data $ rs = $ conn-> Execute ('select * FROM accounts ') or die ("error query");?>