The problem of using FreeTDS to connect MSSQL Chinese garbled in Linux "reference 2"

Source: Internet
Author: User
Tags mssql

php5.3 case, with PDO Dblib driver can not connect MSSQL, according to the official description, 5.2 has modified this bug,5.3 No.

It is possible to use the MSSQL function that comes with PHP. Compile the Freetds,php_mssql,pdo_dblib parameters as follows:
./configure--prefix=/usr/local/freetds--with-tdsver=8.0--enable-msdblib
./configure--with-php-config=/usr/local/php/bin/php-config--with-mssql=/usr/local/freetds/
./configure--with-php-config=/usr/local/php/bin/php-config--with-mssql=/usr/local/freetds--enable-pdo-- with-pdo-dblib=/usr/local/freetds/

With the MSSQL function can not set the charset, set names is not supported, the last reference to ADODB code, found to solve the problem also need to use COM, or with ative MSSQL driver, these two things under Windows can, Linux is not very good. The solution is to edit the/usr/local/freetds/etc/freetds.conf
Add a line of client CharSet = GBK, set to Utf-8 is wrong, because the MSSQL collation database default setting is Chinese PRC, equivalent to gb2312,

In addition php.ini inside Mssql.charset is not need to set, actually said very clearly:
; Specify client character set.
; If empty or not set the client charset from FREETDS.COMF is used
; This was only used when compiled with FreeTDS

This is required when FreeTDS's client charset is empty or not set. Once the wrong to set up here to Utf-8,freetds client CharSet also set to UTF8, the result mssql_connect when the error began. The final conclusion, only need to set FreeTDS client CharSet for GBK, and then inside the PHP program iconv (' GBK ', ' Utf-8//ignore ', $str);

The problem of using FreeTDS to connect MSSQL Chinese garbled in Linux "reference 2"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.