Getting the following error when testing an upgrade to PHP7 x64:
odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I've installed the following:
PHP 7.0.0 x64
Microsoft ODBC Driver 11 for SQL Server x64
Microsoft Visual C++ 2015 Redistributable x64
Microsoft Visual C++ 2015 Redistributable x86
The (thread-safe) preview of the PHP 7 MSSQL drivers: https://github.com/Azure/msphpsql
I have uncommented/added the following lines of my phpini:
extension=php_pdo_mysql.dll (uncommented)
extension=php_odbc.dll (added)
extension=php_sqlsrv_7_ts.dll (added)
extension=php_pdo_sqlsrv_7_ts.dll (added)
Things to consider:
I can see that the modules are indeed loaded in phpinfo.
I've added the ODBC connection and can see it in System DSN.
I am successfully able to connect via sqlsrv_connect() but not odbc_connect(), which is what all our previous PHP 5.6 scripts are using.
Can't seem to find the answer anywhere else. Any help would be appreciated. Thanks.
I seem to have solved my own issue.
Turns out, the ODBC_CONNECT string uses an explicit DSN name and not a database, apparently...
Previously my ODBC Connect string was $conn = odbc_connect('DB',$DBUSER, $DBPASS)
and my ODBC Data Source was "SERVERNAME"
Once I changed the ODBC Data Source name to match the DB name, it worked.
Related
Recently our SQL Server database has been upgraded and my PDO driver stoped working.
Currently im getting error:
SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for
SQL Server to communicate with SQL Server. Access the following URL to
download the ODBC Driver for SQL Server for x64:
https://go.microsoft.com/fwlink/?LinkId=163712
When i connect to the db via MSSMC I see:
Operation System: Microsoft Windows NT 6.3 (14393)
Platform: NT x64
Version: 13.0.5292.0
and my PHP server runs on:
Linux x64
PHP Version 7.2.5
Thread Safely: disabled
Currently PDO Driver is loaded for SQLSRV in version 5.8.0
All was working to recently just fine, from noe on just stopped with that error :(
Can I kindly ask you to help me choose the correct driver file?
from the link in the error its very confusing to choose which .so file it realy should be used.
Thank you
I installed Microsoft SQL Server 2014 (x64)-Express and install the SQL Server Drivers for PHP 7, did changes in php.ini file also, still i am getting error while connecting php to mssql server database 'connection failed. could not find the driver'. Please help me to solve this error.
In my case, in order to access a MS SQL server database from PHP I had to do the following:
Have a PHP version installed that is compatible with microsoft SQL Server executables. Install PDO, PDO_sqlsrv driver and PDO_odbc driver.
Check the following link for instructions on how to install it.
https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver16
I am using PHP 5.6.35, and I have downloaded and installed/enabled the Microsoft SQL Server Drivers for PHP. Specifically, the ones below
extension=php_pdo_sqlsrv_56_nts.dll
extension=php_sqlsrv_56_nts.dll
I can see that they are enabled properly looking at the phpinfo() output. It shows both pdo_sqlsrv as enabled as well as sqlsrv support. However, when I try to connect to my database I get the following error back.
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
[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 assumed I needed to download the ODBC Driver 11 for SQL Server. So I downloaded what I thought was the correct file from here.
https://www.microsoft.com/en-us/download/details.aspx?id=36434
But when I try to install the driver I get an error stating that the installation of this product failed because it is not supported on this operating system. I'm running PHP 5.6.35 on Windows Server 2016.
HELP?
Use the x64 install file. I ran into the same issue and was able to add the 32 bit driver from the x64 installation. I have a 64 bit processors and I tried to test the 32 bit install file for implementation on the x86 systems and seen the same error.
I am attempting to access a mssql 2005 database using Microsoft's supplied sqlsrv drivers. I have tried every driver version from 3.1 to 2.0, installing a different version of XAMPP with different versions of PHP installed.
version 3.1 = php version 5.4.7
error:
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
version 3.0 = php version 5.3.1 error:
This extension requires either the Microsoft SQL Server 2008 Native
Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native
Client ODBC Driver to communicate with SQL Server. Neither of those
ODBC Drivers are currently installed. Access the following URL to
download the Microsoft SQL Server 2008 R2 Native Client ODBC driver
for x86:
version 2.0 = php version 5.2.1 and 5.2.4
Php drivers are unrecognized and do not appear in phpinfo().
I am under the impression the extension should support ALL EDITIONS of SQL Server 2005 and greater...
I installed both the SQL Server 2012 Native Client and the SQL Server 2008 Native Client (SP3).
According to this article I can test the ODBC connectivity to a SQL Server.
Entering odbcping at a command prompt returns:
'odbcping' is not recognized as an internal or external command....
I checked the ODBC Data Source Administrator and found the ODBC Driver 11 for SQL Server is listed in the drivers tab.
Any assistance as to what I may be missing?
You are mixing up two things: ODBC and PHP drivers for MS SQL Server 2005.
If you install SQLDRV 3.X, you dont use ODBC.
If you use ODBC, then you may need different PHP driver than SQLDRV.
I also struggled few hours with setting up PHP connection to MS SQL Server 2003, 2005, 2008 with Studio Express. I used pdo_sqldrv driver installed via SQLDRV drivers provided by Microsoft. Installing PHP drivers was easy part. Once you see pdo_sqldrv in phpinfo(), you are done with PHP driver. Difficult is second part - setting up properly MSSQL environment to allow PHP for connection. I did following steps:
downloaded & installed free MSSQL Studio Express 2005 (or 2008, both work fine)
installed or upgraded to dotNetFx40Setup.exe
installed msxml6.msi (I think this was only needed for version 2005)
installed MSSQL Native Client
logged into studio and created new user for PHP only with read/write permissions
enabled pipe and other connection resources
figured out correct connection string "sqlsrv:server=PCHOME\\SQLEXPRESS;database=eshop"
Then it worked, but definitely it was not easy setup. G'd luck.
I wanted to setup a database connection from PHP to SQL server 2012.I have a wamp server(64 bit) set up on a windows machine(64 bit) with PHP 5.5.12 and on the same machine I have SQL server 2012 installed.
Extracted sqlsrv drivers from official_link
Copied the extracted drivers php_sqlsrv_55_ts.dll, extension = php_pdo_sqlsrv_55_ts.dll to php\ext folder, and then changed the php.ini file to include the extensions
extension = php_sqlsrv_55_ts.dll; extension = php_pdo_sqlsrv_55_ts.dll;
Now I tried
<?php
phpinfo();
?>
I see the following information without any SQL server information in it.
Don't seem to have configured SQL server connection successfully. Could some one please guide me on what I am missing here.
64 bit WAMP server was not able to connect using the drivers extension = php_sqlsrv_55_ts.dll; extension = php_pdo_sqlsrv_55_ts.dll;
So, I installed a 32 bit version of the WAMP server and it works fine now.
Check the php error log (c:\wamp\logs\php_error.log).
I had the same setup (64bit WAMP/PHP 5.5.12) and same missing sqlsrv reference in phpinfo and I got this error in my log:
PHP Warning: PHP Startup: Unable to load dynamic library
'c:/wamp/bin/php/php5.5.12/ext/php_pdo_sqlsrv_55_ts.dll' - %1 is not a
valid Win32 application. in Unknown on line 0
The solution was to install the 64bit version of the sqlsrv drivers. I found the unofficial 64bit drivers through http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html
Warning: In my testing I found these 64bit PHP_PDO_SQLSRV extension 10 times slower than when using PHP_PDO_ODBC.
I am visiting this thread and i think this might help full for you and other with the same issue:
How can I install pdo_sqlsrv on my windows 2008 Server 2008 R2?
The PDO Extension is not the same as the native driver Microsoft is offering. For PDO you must enable
extension=php_pdo_mssql.dll
in your php.ini.
{Normally this file (php_pdo_mssql.dll) should be in your PHP extension-directory (C:...\php\ext). If it's not there you can download PHP from http://windows.php.net/download/ and just take the extension from a package there (take one that correspond with your PHP version of course)}.
Above is taken from PDO MSSQL Server - Driver not found
read for more details. i have the same issue foe linux and i have saved all the pages thats why i am quoting for you help.
if all above didn't work for you then:
On the php.net it is listed that
On Windows, PDO_ODBC is built into the PHP core by default. It is linked against the Windows ODBC Driver Manager so that PHP can connect to any database cataloged as a System DSN, and is the recommended driver for connecting to Microsoft SQL Server databases.
http://php.net/manual/en/ref.pdo-odbc.php
You can connect to mssql server using odbc drivers as i have never connect by my self from windows i use to do it through linux using freeTds, following pages might help you
http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/
Connect PHP to MSSQL via PDO ODBC
PHP to SQL Server without ODBC or MSSQL support