PHP connects to SQL Server in PDO mode, unable to open sqlsrv extension

Source: Internet
Author: User

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

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.