PHP MsSQL WAMP - Couldn't connect to MSSQL - php

I've downloaded SQLSRV32.EXE from the official MSSQL Driver for PHP and extracted php_sqlsrv_56_ts.dll & php_pdo_sqlsrv_56_ts.dll into C:\wamp\bin\php\php5.6.19\ext
Added the following declaration in the php.ini from the WAMP menu.
extension=php_pdo_sqlsrv_56_ts.dll
extension=php_sqlsrv_56_ts.dll
I then run the sample code from the reference page.
I couldn't connect to the MS SQL Server due to the following error
Connection could not be establish
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server 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 ) )
I've tried to download the ODBC Driver 13 (for Windows 10) but it is not working. Can someone tell me what I'm doing wrong?

As I can see - ODBC Driver 13 is not supported on your system and the required one is ODBC Driver 11.
https://www.microsoft.com/en-us/download/details.aspx?id=36434

Related

ODBC Driver 11 for SQL Server

I'm using the SQL Server 2008 installed in a remote desktop. And I am trying to access it using PHP.
I have downloaded the PHP drivers. The Registered PHP Streams in phpinfo includes sqlsrv.
So if the following error pops the ODBC driver should be installed in my system or in remote desktop. I'm using PHP Version 7.0.8, so I need ODBC Driver 11 or 13?
Connection failureArray
(
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -49
[code] => -49
[2] => This extension requires the Microsoft ODBC Driver 11 or 13 for SQL Server. Access the following URL to download the ODBC Driver 11 or 13 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712
[message] => This extension requires the Microsoft ODBC Driver 11 or 13 for SQL Server. Access the following URL to download the ODBC Driver 11 or 13 for SQL Server 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
)
)

PHP: ODBC 11 does not support connections to sql server 2000 or earlier version

I'm trying to connect to MS SQL using sqlsrv_connect, before I installed ODBC 11 I got error that required to install ODBC 11 so I installed it. After i Install I got another error message again
Array
(
[0] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => 22
[code] => 22
[2] => [Microsoft][ODBC Driver 11 for SQL Server]ODBC Driver 11 for SQL Server does not support connections to SQL Server 2000 or earlier versions.
[message] => [Microsoft][ODBC Driver 11 for SQL Server]ODBC Driver 11 for SQL Server does not support connections to SQL Server 2000 or earlier versions.
)
[1] => Array
(
[0] => 08001
[SQLSTATE] => 08001
[1] => 22
[code] => 22
[2] => [Microsoft][ODBC Driver 11 for SQL Server]Client unable to establish connection
[message] => [Microsoft][ODBC Driver 11 for SQL Server]Client unable to establish connection
)
)
Is this possible to connect these connections?
function access_store($ips){
$conInfo = array("Database"=>"site5");
$conn = sqlsrv_connect($ips, $conInfo);
if($conn){
echo'Connection SUccess';
}else{
die('<pre>'.print_r( sqlsrv_errors(),true ).'</pre>');
}
}
What version Microsoft PHP sql driver installed? You need an older version of the driver.
Tech republic has a good article
Tech republic
Microsoft SQL server driver

Using ODBC Driver 13 instead of ODBC Driver 11 to Connect to SQL Server 2008 R2

I am trying to connect to my MS SQL Server (2008 R2) with php and xampp. Upon running the code I got this error:
Connection could not be established.Array
(
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -49
[code] => -49
[2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712
[message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server 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
)
)
So, I decided to try to install the ODBC Driver 11. I could not install the driver on Windows 10 because it's not supported so I downloaded ODBC Driver 13 and it still did not work. Is there a way I can reconfigure ODBC Driver 13 so it will work in replace of ODBC Driver 11? If there is anything else I can provide that would be useful let me know. I cannot use MySQL for this, nor can I update SQL Server.
PHP SQL Server Couldn't connect
PHP 5.5 and MSSQL driver: Installing ODBC Driver 11 in Windows Server 2012 R2
To make an addition, make sure you installed the correct version (32-bit vs 64 bit) of ODBC!
Know which version your system runs: your SQL server might be a different version.
Even if these questions don't solve it directly, they might contain useful information for your situation.
Refer to these questions; I think you should be able to find a solution.
The DLL file of ODBC might need to be copied under your working directory of PHP in addition to being installed.
I see that being a common problem with JDBC at least.
Good luck!

Connecting to database on SQL server from WAMPSERVER 2.5

I've got a WAMPSERVER 2.5 development server. It's running PHP 5.512.
I'm trying to connect to our live SQL Server. I've installed and activated the version 32 files, and used the following code:
<?php
$link = sqlsrv_connect('obscured_ip:obscured_port', array('Database'=>'obscured_database','UID'=>'obscured_uid', 'PWD'=>'obscured pwd'));
if (!$link)
die(print_r(sqlsrv_errors(), true));
?>
I'm getting the following error:
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP 1 => -49 [code] => -49 2 => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server 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 ) )
The link specified there just takes me back to the driver download page. What am I doing wrong?
The URL in the error points to the wrong page. This is the correct one: https://www.microsoft.com/en-us/download/details.aspx?id=36434

Can anyone decipher an error message I get when trying to store form data on MS SQL using php?

I attempted to connect to an Microsoft SQL database and store html form data in it using php but was unable to.
At first I attempted using the mssql syntax but realized that it was abandoned past 5.2 (I'm running 5.3). Then I attempted to connect using the sqlsrv syntax but that required a driver and editing the php.ini file -- which I did only to receive this error message pertaining to the MS SQL Native Client:
> Connection COULD NOT be establishedArray ( [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 ) )
A phpinfo file shows that sqlsrv is installed and I've deleted and reinstalled the drivers and native client twice already to no avail..........
Here is the stack:
Windows 2003 server
IIS 6 web host
local install of MS SQL 2008 (previously was attempting to connect to a remote MS SQL 2014 database
PHP version 3.1.3

Categories