PHP connection to SQL Server encountered a lot of problems, here the detailed steps to record, for your reference:
First of all my is phpstudy-5.4, such as;
First step: Download sqlsrv
Address:http://www.microsoft.com/en-us/download/details.aspx?id=20098
Download is a self-extracting file, after decompression will have a bunch of DLL files
The second step: copy the corresponding PHP version of the DLL file to the PHP ext directory
Version is php5.4, copy the Php_sqlsrv_54_ts.dll to the EXT directory
Step three: Modify the php.ini file
Add one line: Extension=php_sqlsrv_54_ts.dll
Modify one line: Mssql.secure_connection = Off to On
Fourth Step: Restart Apache
Fifth step: Install Microsoft SQL Server Native Client.msi
Install Microsoft SQL Server Native Client.msi, sub-X64 and X86 according to your system on the machine where the PHP server is located.
Http://www.softpedia.com/get/Internet/Servers/Server-Tools/SQL-Server-Native-Client.shtml
Sixth step: PHP code to determine whether the connection is successful
<?php
Header ("Content-type:text/html;charset=utf-8");
$conInfo =array (' Database ' = ' test ', ' UID ' = ' test ', ' PWD ' = ' 123456 ');
$conn =sqlsrv_connect (' 12.14.27.116 ', $conInfo);
/* Determine if the connection is successful or not: */
if (! $conn) echo "faild! connection error, user name password is not correct";
else echo "ok! can be connected";
?>
PHP Connect SQL Server steps in a detailed