PHP5.6.15 connecting SQL Server 2008 Configuration Scenarios

Source: Internet
Author: User
Tags microsoft sql server sql server driver

php5.6 If you want to connect to a SQL Server 2008 database, you need to manually configure the extension and install a driver.

Download SQL Server Driver for PHP extension pack, 64-bit system is not officially supported, find an unofficial:

Http://pan.baidu.com/s/1o7FVblw

Unzip copy inside DLL file into PHP ext folder inside

Open a php.ini file to add the following two extensions:

Extension=php_pdo_sqlsrv_56_ts. dllextension=php_sqlsrv_56_ts.dll

Restart Apache after saving php.ini.

View Phpinfo:

The pdo_sqlsrv extension is already open.

Finally, you need to install the Microsoft SQL Server Native Client.msi driver on the server where PHP is located to successfully access the SQL Server 2008 database.

Http://pan.baidu.com/s/1miMuYF2

Look at the effect:

     Public functionTestsql () {Try {            $servname= "12.36.112.11"; $conninfo=Array("Database" = "MyDatabase", "UID" = "sa", "PWD" = "123456789"); $conn=sqlsrv_connect ($servname,$conninfo); if($conn)Echo"Conect Success"; Else Echo"Connect Failed"; $sql= "SELECT * FROM Users"; $db=sqlsrv_query ($conn,$sql);  while($row=sqlsrv_fetch_array ($db))            {                Echo $row["Username"]; }        }        Catch(Exception $e){}    }

The data was successfully acquired

PHP5.6.15 connecting SQL Server 2008 Configuration Scenarios

Related Article

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.