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