First, the PHP connection SQL Server code is as follows:
$host= "AAAAA";$dbname= "AAAAA";$user= "AAAAA";$pass= "AAAAA";Try { #MS SQL Server and Sybase with Pdo_dblib $DBH=NewPDO ("sqlsrv:server=$host;D atabase=$dbname",$user,$pass);} Catch(pdoexception$e) { Echo $e-getMessage ();}
In the local environment test is normal, to the server environment (with Phpmanger for IIS deployed on Windows IIS PHP environment, while supporting PHP and ASP) error, "Unable to open this extension" and so on, the workaround is as follows:
1. The server is 64-bit windows2008, the official website of the sqlsrv can not be loaded successfully, only use the unofficial compiled 64-bit version, Link:
Http://robsphp.blogspot.co.uk/2012/06/unofficial-microsoft-sql-server-driver.html
Or
Http://pan.baidu.com/s/1dDIRpJF
2. After opening the extension, you will also need to download Microsoft ODBC Driver one for SQL Server
Link: https://www.microsoft.com/en-us/download/details.aspx?id=36434.
PHP connects to SQL Server in PDO mode, unable to open sqlsrv extension