I am gettin following error when I connect to mssql
Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: This extension requires the Microsoft SQL Server 2012 Native Client ODBC Driver to communicate with SQL Server
And I am using
$db = new PDO("sqlsrv:server=127.0.0.1;database=test;", "sa", "mypassword");
I have also added driver in C:\xampp\php\ext and set that extension in php.ini file
[PHP_PDO_MSSQL]
extension=php_pdo_sqlsrv_54_ts.dll
I have tried several tutorials, what exactly I am doing, Please tell what I am doing wrong?
what version of the php pdo sqlsrv are you using?
Try updating it to v3.1
http://www.microsoft.com/en-us/download/details.aspx?id=20098
You might neet the ODBC driver as well:
http://www.microsoft.com/en-us/download/details.aspx?id=36434
Related
I am creating a web application in php 7.2 and need to connect to a Sybase database. I am using Doctrine orm.
I have tried using the sqlanywhere driver and the pdo_sqlsrv driver to connect to Sybase.
However with sqlanywhere I am getting the error:
Warning: sasql_pconnect(): SQLAnywhere: [-832] Connection error: Connection was dropped (may not be a SQL Anywhere server)
With pdo_sqlsrv I get the error:
PDOException: SQLSTATE[HY000]: [Microsoft][ODBC Driver 13 for SQL Server]Protocol error in TDS stream.
I have googled both these errors and have not been able to resolve either.
Does anyone have any suggestions for how to connect to Sybase using php7.2 and Doctrine orm?
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
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.
I'm trying to connect a new project CakePHP v3 installed in a common LAMP on Ubuntu Server and the DataBase is a MSSQL 2008. I've tried to install the library php5-mssql but nothing changes. Any idea?
The error message received is:
CakePHP is NOT able to connect to the DataBase.
DataBase driver Cake\Database\Driver\Sqlserver cannot be used due to a missing PHP extension or unmet dependency
Thanks!
CakePHP does not have an ODBC driver at this time. You can connect to MSSQL servers using the SQLServer driver from a Windows server, but this issue (https://github.com/cakephp/cakephp/issues/6990 ) just keeps getting bumped.
Since Cake3 uses PDO drivers to connect SQL Server (from Linux), you should try to install Microsoft ODBC Driver for Linux, see
http://onefinepub.com/2013/03/ms-sql-odbc-ubuntu/
it may helps
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