0

I am trying to connect my PHP with SQL Server. I have to go to the field to test it, so I was configuring a laptop with the necessary settings. In the desktop I currently work at, the connection works properly. But in the laptop, it won't connect. Here is the code I am using:

$serverName = "server"; //serverName\instanceName

$connectionInfo = array( "Database"=>"DB", "UID"=>"user", "PWD"=>"pass");
$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));
}

I have placed the .dlls in the ext file and I have written the extension in the php.ini but somehow it still won't work. This is the error I am getting:

Connection could not be established.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )

Any help will be appreciated. Thank you.

3
  • 1
    Read the error, it looks like you need to download the SQL Server client on your laptop: go.microsoft.com/fwlink/?LinkId=163712 Commented Mar 7, 2013 at 15:43
  • The thing is I already have it Commented Mar 7, 2013 at 15:47
  • Consider using PDO for more flexibility. Commented Oct 8, 2014 at 15:33

2 Answers 2

1

http://www.microsoft.com/en-us/download/details.aspx?id=29065#SNAC

This is the answer. I downloaded the Microsoft® SQL Server® 2012 Native Client and everything worked like a charm. I searched high and low for this link so now I share it here in hopes to help anyone who is looking for it like me.

Sign up to request clarification or add additional context in comments.

1 Comment

There are number of products to download but there is no product with name Microsoft® SQL Server® 2012 Native Client. Which product you downloaded to resolve this issue?
0

@plasmy, thanks for this. I also have searched all over to get this working. The download link on top of the page gives you a text file with instructions on how to download the file, which is seriously wtf. The direct link for the native client is here:

http://go.microsoft.com/fwlink/?LinkID=239648&clcid=0x409

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.