PHP PDO : Charset=UTF8 : An invalid keyword charset was specified in the dsn string

后端 未结 1 1759
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 18:15

I am connecting to an MS SQL server with PDO using the sqlsrv driver.

PHP version is 5.3.24. The working connection looks like this:

$dsny = \"sqlsrv         


        
相关标签:
1条回答
  • 2021-01-18 19:17

    You need to apply the attribute after connecting:

    $dbhy->setAttribute(PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_UTF8);
    

    See: https://msdn.microsoft.com/en-us/library/ff628157(v=sql.105).aspx

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