PHP + SQL Server - How to set charset for connection?

前端 未结 13 1004
借酒劲吻你
借酒劲吻你 2020-12-01 06:54

I\'m trying to store some data in a SQL Server database through php.

Problem is that special chars aren\'t converted properly. My app\'s charset is iso-8859-1 and th

相关标签:
13条回答
  • 2020-12-01 07:16

    In my case, It worked after I added the "CharacterSet" parameters into sqlsrv_connect() connection's option.

    $connectionInfo = array( 
            "Database"=>$DBNAME,
            "ConnectionPooling"=>0,
            "CharacterSet"=>"UTF-8"
    );
    $LAST_CONNECTION = sqlsrv_connect($DBSERVER, $connectionInfo);
    

    See documentation here : https://docs.microsoft.com/en-us/sql/connect/php/connection-options?view=sql-server-2017

    0 讨论(0)
提交回复
热议问题