PHP 7 on IIS: Call_user_function could not be located - php

I am trying to use the Microsoft SQL Server drivers with PHP 7.1 Not Thread Safe x64 on Windows 2012 R2 64-bit server.
No matter what I do I am getting an error when I run php from a admin command prompt
Warning: PHP Startup: Unable to load dynamic library
'ext\php_pdo_sqlsrv_7_nts.dll' - The specified procedure could not be
found.
Additionally it display a windows pop up that states
The procedure entry point call_user_function could not be located in
the dynamic link library C:\PHP7\ext\php_pdo_dqlsrv7_nts_x64.dll
I have verified that the php.ini is pointing to a file that exists, because if I rename the .dll file, the error messages changes to "specified module could not be found", instead of specified procedure.
I have installed Microsoft Visual C++ runtime 15 x64 as required by PHP 7.
I have installed Microsoft ODBC driver 13 as required by the Microsoft SQL Server driver.
I have rebooted the server twice.
There is nothing else I can think to even try. The Microsoft WinCache.dll is loading and working fine in PHP, as verified by phpinfo.

Confirmed what #MEmerson said above. You need to downgrade PHP to 7.0.X(?) - I used 7.0.12.
Complete Setup:
Windows 10 Pro
PHP X64 7.0.12 TS (Bitnami WAMP Stack)
Microsoft ODBC Driver 13.1 for SQL Server (https://msdn.microsoft.com/en-us/library/mt703139(v=sql.1).aspx)
Microsoft Drivers for PHP for SQL Server 4.0 (https://www.microsoft.com/en-ca/download/details.aspx?id=20098)
Same drivers with PHP X64 7.1.0 produced the error you are getting.

Microsoft Drivers 4.3 for PHP for SQL Server are now available.
These drivers contains files for PHP 7.1 - php_pdo_sqlsrv_71_nts_x64.dll etc.
I've successfully managed to connect to SQL server.

Had similar error when tried to use httpd (Apache), PHP 7.2.2, Microsoft ODBC driver 11 on MS Windows Server 2012. The text of error was:
The procedure entry point call_user_function could not be located in the dynamic link library php_pdo_sqlsrv_7_ts_x64.dll.
when I called php -m to check modules.
So I have downloaded Windows-7.2.zip from https://github.com/Microsoft/msphpsql/releases and used thread-safe dlls from it.
php -m works now as it should without giving error.

Same as NoCopy
Windows Server 2012
php-7.0.15-Win32-VC14-x64.zip from (http://windows.php.net/download)
Visual C++ Redistributable for Visual Studio 2015 (https://www.microsoft.com/en-us/download/details.aspx?id=48145)
Microsoft ODBC Driver 13.1 for SQL Server
Microsoft Drivers for PHP for SQL Server 4.0
7.1.x still a No,NO from Microsoft

It happened to me today while enabling the extensions in the IIS, where I by mistake enabled different versions for pdo & driver extensions (E.g. php_sqlsrv_7_nts_x86.dll for PHP 7.0 & php_pdo_sqlsrv_72_nts_x86.dll for PHP 7.2).
Usually the package that you download from Microsoft that contains Microsoft Drivers 5.3 for PHP for SQL Server has all the PHP extensions versions. https://www.microsoft.com/en-us/download/details.aspx?id=57163
Just make sure you enable both extensions for the same versions to avoid that error.

Related

php_pdo_sqlsrv_55_ts.dll bindValue crash

I'm developing a PHP application that connects to MSSQL on windows environment, I have
Windows Server 2008 R2 Enterprise - 64-bit operating system
WAMP 2.5 - 64-bit (Apache 2.4.9 / PHP 5.5.12)
I've installed the official Microsoft SQL PDO Drivers (php_pdo_sqlsrv_55_ts.dll, php_sqlsrv_55_ts.dll)
I've connected to the database successfully, and executed different queries
I've two problems
Every time the WAMP starts I found these errors in the error 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
PHP Warning: PHP Startup: Unable to load dynamic library
'c:/wamp/bin/php/php5.5.12/ext/php_sqlsrv_55_ts.dll' - %1 is not a
valid Win32 application. in Unknown on line 0
When I try to use PDO method (bindValue) ... the page crashes .. don't throw specific error or warning or anything .. just this message in the browser "This site can’t be reached" ... and the same two errors appear in the PHP error_log
The PDO_SQLSRV is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MS SQL Server (starting with SQL Server 2005).
The extension is enabled by adding appropriate DLL file to your PHP extension directory and the corresponding entry to the php.ini file, which appears to have been done in your installation. The PDO_SQLSRV file download comes as 8 driver files, 4 of which are for PDO support.
The ts/nts abbreviation in file names below means Thread-safe /Non-thread-safe respectively.
If you are running non-thread-safe PHP (PHP 5.3), use the php_pdo_sqlsrv_53_nts.dll file. (You should use a nts version if you are using IIS as your web server).
If you are running ts PHP, use the php_pdo_sqlsrv_53_ts.dll file.
Similarly for PHP 5.4, use the php_pdo_sqlsrv_54_nts.dll or php_pdo_sqlsrv_54_ts.dll depending on whether your PHP installation is non-thread-safe or thread-safe.
The most recent version of the driver is available for download here. If you need support for PHP 5.2 and/or PHP compiled with VC6, use the 2.0 release of the driver.

sqlsrv drivers doesn't appear on a WAMP server phphinfo() after adding the extension entries in the php.ini file

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

Installing SQL Server driver for PHP

I have installed:
Windows Server 2008 R2 x64
IIS 7
PHP 5.5 (5.5.9) VC11 x64 Non Thread Safe (2014-Feb-06 00:36:15)
MSVC11 (Visual C++ 2012)
Sql Server 2008
Sql Native Client
Everything works perfectly except the MSSQL driver for PHP. I have Googled a lot and downloaded lots of dll files. Every time I get this error:
PHP Warning: PHP Startup: Unable to load dynamic library c:\php\ext\php_sqlsrv_54_nts.dll - %1 is not a valid Win32 application.
in Unknown on line 0
Can anyone tell me that how can I find the specified driver? Thanks in advance.
There's a clue in the file name php_sqlsrv_54_nts.dll
The "54" refers to PHP 5.4. The SQL Driver doesn't (officially) exist yet for PHP 5.5.
:(
Some people have worked on unofficial builds, but I would only use them for local testing.
Microsoft sqlsrv extension for php 5.5.x
At present official releases only work with 5.4.x
Here is a page from my blog with instructions on how to install the driver: http://robsphp.blogspot.com/2012/09/how-to-install-microsofts-sql-server.html
Look for text written in in orange which refers to my builds of the driver that support PHP 5.5 32 and 64 bit.
If you only want Microsoft's builds, avoid looking at anything written in orange.
Sharing some of my findings:
Architecture matters(x86 / x64)
PHP version matters a lot
Matching SQL Driver Should be installed.
Refer This Link to find whether your PHP version supports the driver (Refer the first table).
Refer Rob's Answer to find your Architecture and TS/NTS (Thread Safe/Non Thread Safe) of Your PHP This is His Blog
This is what worked out for me: I tried with Wampp - 64bit, Selected PHP 7.0.10 downloaded MYSQL Driver version 5.3 (Note: Refer the table i mentioned- 4th point to get the correct version)
Saved only the 64 bit TS (php_sqlsrv_7_ts_x64.dll, php_pdo_sqlsrv_7_ts_x64.dll) because my php was Thread Safe (You can find yours by refering 5th point) into the E:\wamp64\bin\php\php7.0.10\ext folder.
Added extension=php_sqlsrv_7_ts_x64.dll and extension=php_pdo_sqlsrv_7_ts_x64.dll to the php.ini, selected from wampp menu (E:\wamp64\bin\apache\apache2.4.23\bin\php.ini).
Restarted Wampp, and it works perfect.
For those who face call to undefined function sqlsrv_connect() also can follow this technique.

Not getting connected to Sql Server 2012

I am getting following error while connecting to Sql Server 2012 in Laravel 4
PDOException SQLSTATE[IMSSP]: This extension requires the Microsoft
SQL Server 2012 Native Client ODBC Driver to communicate with SQL
Server. Access the following URL to download the Microsoft SQL Server
2012 Native Client ODBC driver for x86:
http://go.microsoft.com/fwlink/?LinkId=163712
As per this link
http://msdn.microsoft.com/en-us/library/cc296170.aspx
I downloaded and installed these two files in xampp/php/etc/ folder
php_sqlsrv_54_ts.dll
php_pdo_sqlsrv_54_ts.dll
And added these two in the php.ini file. But still I am seeing the same error.
I am using windows 7 and xampp. Please help.
I removed Xampp and installed Wamp (32 bit) server on my Windows 7, because after following almost every tutorial my xampp installation became unstable.
Following are the steps that resulted in successful connection to SQL SERVER 2012.
Download Microsoft SQL Driver for PHP
http://www.microsoft.com/en-in/download/details.aspx?id=20098
Click on the exe to extract it copy below two dlls
Add Extensions in the D:\wamp\bin\apache\Apache2.4.4\bin\php.ini
extension=php_pdo_sqlsrv_54_ts.dll
extension=php_sqlsrv_54_ts.dll
After that I downloaded and installed this Microsoft Sql Server 2012 SP1 Feature Pack
http://www.microsoft.com/en-in/download/details.aspx?id=35580
After this restart your computer.You should see these two blocks in your phpinof() output
thats it. Hope this will help someone.

"could not find driver" using sqlsrv for PDO

We're trying to set up a work environment using the following specs:
Symfony 2.3.4
MS SQL Server 2008
PHP 5.5.6, x86, thread safe
SQLSRV PDO drivers for PHP 5.5
Windows 7 x64
XAMPP 1.8.3, Apache is x86
SQL Server 2012 Native Client, x64 (x86 could not be installed)
Visual C++ (can't remember the version) x86 and x64
However, when we try to make a query to the database, we get a "could not find driver" error and no operation can be done. In the phpinfo() I can see the drivers are not registered properly and I get two errors when Apache loads, but none has a message and in the PHP logs the error is "unknown" at line 0.
What could be the problem? Thank you beforehand.
The issue was that I didn't have the Visual C++ Redistributable package. I realized this after rebooting the computer and getting a MSVCP110.dll missing error in a system dialog box rather than a dialog box from XAMPP.
If anyone else is having this very same issue, download Visual C++ Redistributable for Visual Studio 2012 Update 4 here, in the Microsoft website. Although the computer works with a x64 architecture, I downloaded the x86 version and it worked. Make your choice but I'd recommend doing the same, because PHP is x86 only (x64 is merely experimental and the drivers are x86 aswell).

Categories