5

I went through several questions and recommendation to resolve the above issue, but No luck at all.

I have the following settings:

Windows Server 2008 R2

xenter image description hereampp-win32-1.8.2-5-VC9-installer

SQLSRV30 - php driver

sqlncli - Microsoft SQL Server 2008 R2 Native Client Set Up

I installed everything else and I have the following on the php.ini file The code below show where the php drivers are residing:

; On windows:
extension_dir="C:\xampp\php\ext"

enter image description here The following is under windows extensions

extension=php_pdo_sqlsrv_54_ts.dll
extension=php_sqlsrv_54_ts.dll

enter image description here

When I check the phpinfo file sqlsrv is not listed. I know this may imply that its not installed, but It is installed.

The following is the php info file:

I also restarted apache and the server. Am I missing something ?

I get the following error:

Call to undefined function sqlsrv_connect()

This the code I am using to connect: I am connecting to another server which is hosting SQL Server 2005

/Connection to SQL Server Database
    error_reporting(E_ALL);
$serverName = "172.xx.x.xxx";

$connectionInfo = array('Database'=>'Eque', "UID"=>"develop", "PWD"=>"develop");
$conn = sqlsrv_connect($serverName, $connectionInfo);


if($conn) {
     echo "Connection established.<br />";
}else {
    echo  "Connection could not be established.<br />";
    die(print_r(sqlsrv_errors(), true));
}
3
  • did you enabled those modules in php.ini file. If it is not there please add it and restart the server Commented Jul 16, 2014 at 8:50
  • Yes, @Sundar I un-commented the modules on the php.ini file by removing ; Commented Jul 16, 2014 at 8:54
  • after enabling the ini settings don't forget to restart the apache server Commented Jul 16, 2014 at 9:04

3 Answers 3

8

I have struggled through the process and this is what has finally worked. I am using php 5.4.16 and Apache 2.4.4 with Sql Express 2008 R2.

  1. Download Microsoft Drivers for PHP for SQL Server from Microsoft download site

  2. Extact the files to a local folder

  3. Copy php_sqlsrv_54_ts.dll and php_pdo_sqlsrv_54_ts.dll to the Ext folder (C:\wamp\bin\php\php5.4.16\ext). You can confirm the folder by checking the value of extension_dir in php.ini file stored under Apache (C:\wamp\bin\apache\Apache2.4.4\bin).
  4. Add extension for the two drivers by adding these lines: extension=php_sqlsrv_54_ts.dll extension=php_pdo_sqlsrv_54_ts.dll and comment out the existing lines below if not commented: ;extension=php_pdo_mssql.dll ;extension=php_mssql.dll
  5. Start all Wamp services
Sign up to request clarification or add additional context in comments.

Comments

4

Load the PHP drivers in php.ini file and restart the server.

extension=php_sqlsrv_53_ts.dll
extension=php_pdo_sqlsrv_53_ts.dll

Reference: http://technet.microsoft.com/en-us/library/cc296203(v=sql.105).aspx

TS denotes thread safe. find your server is thread safe or non thread safe

13 Comments

I am using php 5.4.27. isn't the drivers you are recommending for php 5.3 ?. I attached the phpinfo file for more details
This should work. Still they not released 5.4 anyway check it up again in the drivers folder.. what you pasted in the ext folder. if you 54 use that or use 53. 53 will work i used it before
use this function to test your loaded extensions php.net/manual/en/function.extension-loaded.php
Still no luck. Its not part of the loaded extensions
I am considering installing sqlexpress locally to test it. I will post any changes after installation.
|
0

What worked for me on windows 10 64bit and php 5.6. is the 3.2 version of the driver downloaded from here:Microsoft SQL Server driver for PHP

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.