php_pdo_sqlsrv_55_ts.dll bindValue crash - php

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.

Related

php throws exception "Call to undefined function oci_connect()"

Here is my configuration:
Window Server 2016 build 14393
From phpinfo:
PHP Version 8.1.5
Architecture X64
Server API CGI/FastCGI
Loaded configuration file: D:\php\php.ini (expected)
PHP API: 20210902
PHP Extension: 20210902
from php.ini
extension=oci8_12c ; Use with Oracle Database 12c Instant Client
Notes:
This php.ini file works on my laptop and another windows 16 server (both running Apache). On this server, we are running php over IIS
many of the extension sections are missing from phpinfo listing including oci8 and odbc.
If I do a php --ri I get screenful of warnings telling me for example:
PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: d:\php\ext\curl (The specified module could not be found), d:\php\ext\php_curl.dll (The specified module could not be found)) in Unknown on line 0
but in every case I tested, the 'missing' dll does exist in the specified folder.
execution of tnsping from d:\app\oracle\product\12.2.0\client_1\bin\tnsping.exe:
TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 28-APR-2022 16:51:58
first part of path:
PATH=C:\Windows\system32\inetsrv;
D:\app\oracle\product\12.2.0\client_1\bin;
C:\Windows\system32;
I did not determine root cause for why my extensions were not loading. However, I was able to get them to load. Here is what I did:
removed php-cgi entry from IIS fast-cgi section
removed php-cgi entry from IIS http-mapping section
deleted d:\php folder
From IIS manager, added php 7.4 (64 bit) [latest version available in platform manager] using platform manager
enabled OCI8_12c using IIS/PHP Manager -- at this point, my application works
unzipped php 8.15 to d:\php
used IIS/PHP Manager to register new version, pointing to d:\php\php-cgi.ee
used IIS/PHP Manager to enable OCI8_19
restarted IIS -- now my application works fine as php 8.15 under IIS

PHP 7 on IIS: Call_user_function could not be located

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.

SQLSRV works for CLI only but not from APACHE webserver

I am using sqlsrv to connect to an MS SQL database on my localhost without any problem. Recently, I have installed the 'sqlsrv' driver on a test server running Windows Server 2012 R2, that uses the same version of PHP as my localhost (php 5.5.19 - xampp).
Running database scripts from CLI of the test server works PERFECTLY fine.
eg: "D:\MYXAMPP\php\php.exe D:\MYXAMPP\htdocs\test\test.php" will connect to an mssql db, select some content and print it to screen without error.
However, same scripts complain driver not found when opened from Web interface. I tried checking php error logs, and i found a startup error
"PHP Warning: PHP Startup: Unable to load dynamic library 'D:\MYXAMPP\php\ext\php_sqlsrv_55_ts.dll' - The specified module could not be found.
PHP Warning: PHP Startup: Unable to load dynamic library 'D:\MYXAMPP\php\ext\php_pdo_sqlsrv_55_ts.dll' - The specified module could not be found."
I tried restarting apache but same error keeps showing up. What could be the problem?
I found a solution this problem. It turns out the server environment Visual C++ Redistributable x86 version. As pointed out in this answer, the architecture of sqlsrv extension is x86, thus requires the x86 VC++ even on a x64 machine.
I noticed this when starting apache using a batch script distributed with xampp, instead of using the xampp control panel, a pop up would occur stating "Missing MSVCP110.dll", which I found was linked to VC++ 2012. I downloaded it from microsoft's website, and restarted apache without any errors. From there on SQLSRV has been working fine for both APACHE and CLI interfaces.
I still don't know why in the first place the CLI php API loaded the extension, while the apache php API couldn't in the same environment. I am researching that.

Is there MSSQL Server Driver for PHP on a 64-bit environment?

Is there a driver for MSSQL Server for PHP (64-bit)?
I have Apache 2.4 (64-bit) environment installed. Also PHP 5.5.12 (64-bit)
I have search for MSSQL Server driver "on the net" for php 64-bit but I found nothing. All I can find is a 32-bit. Also, all the articles that I found were old and nothing recent.
I tried to install the 32-bit driver but I get a warning when executing C:\php>php -m
This is the warning
PHP Warning: PHP Startup: Unable to load dynamic library 'ext\php_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application. in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'ext\php_pdo_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application. in Unknown on line 0
I downloaded the MSSQL Server Driver from Microsoft Drivers 3.0 for PHP for SQL Server
If there a MSSQL Server driver available for PHP 64-bit environment?
If not is there a workaround beside having to go back to 32-bit PHP environment?
I have run into this issue as well. What I have found is that you need to make sure that the extension=php_sqlsrv_54_ts.dll area of your php.ini file is only uncommented on the Apache location of php.ini.
For example:
if you have C:\Webserver\bin\apache\bin\php.ini, you probably have a C:\Webserver\bin\php\php.ini as well. Make sure your extension referrences are ONLY in the ...\apache\bin\php.ini.
It took me 3 hours to realize there were 2 different php.ini files and that the error was throwing because I had the extension initialized in the wrong php.ini file yet it was still looking there for some reason. I hope this helped.
Have you tried updating to php 7 ?
The x64 builds of PHP 5 for Windows are experimental, and do not provide 64-bit integer or large file support. Therefore I doubt MS will release a php5 version of the driver especially since the one for php 7 has been out for a few months now.
This MSSQL driver was release in July of 2016
Download the "SQLSRV40.EXE" from https://www.microsoft.com/en-us/download/details.aspx?id=20098
The executable is a self-extractor, unpack where you want.
You even get the PDO for the same price.
Here are the files in the package
PHP Drivers License Terms.rtf
php_pdo_sqlsrv_7_nts_x64.dll
php_pdo_sqlsrv_7_nts_x86.dll
php_pdo_sqlsrv_7_ts_x64.dll
php_pdo_sqlsrv_7_ts_x86.dll
php_sqlsrv_7_nts_x64.dll
php_sqlsrv_7_nts_x86.dll
php_sqlsrv_7_ts_x64.dll
php_sqlsrv_7_ts_x86.dll
release.txt
SQLSRV_Readme.htm
SQLSRV_ThirdPartyNotices.rtf
Tested with php 7.0, 7.1, 7.2

PHP (WAMP) OCI8 driver setup problem

Greetings,
I need to install oci8 drivers for PHP, but I’m having some trouble.
I already have a WAMP install, which comes with the oci8 extension, and have done the following in effort to set it up:
Enabled the extension by adding the following to my php.ini file in my Apache docroot as a local variable:
[PHP_OCI8]
extension=php_oci8.dll
Added my extensions directory path to my PATH environment variable on windows (c:/wamp/bin/php/php5.3.0/ext/;)
Added the same extensions directory to my php.ini file
When I start up my wamp I see the following error message:
PHP Startup: Unable to load dynamic library ‘c:/wamp/bin/php/php5.3.0/ext/php_oci8.dll’
I’m able to verify that the above path is correct, and am tempted to say that there’s something wrong with the .dll, but I’m not sure.
Has anyone experienced similar issues?
The Oracle OCI8 driver also requires that the Oracle Instant Client 10gR2 (aka 10.2.x) libraries or newer be installed on the machine PHP is running on. It is recommended you use either the Basic or Basic Lite version depending on if you need the internationalization libraries or not.
Win32 Instant Client Download Page
Win64 Instant Client Download Page
An annotation: I recently had the task of installing PHP 5 on a Windows system with Oracle HTTP Server 10g. PHP <= 5.0 requires an Oracle 8i or 9i client, PHP >= 5.1 requires an Oracle 10gR2 client or above. The Oracle HTTP Server 10g deploys an Oracle 10gR1 client which is not at all supported by PHP 5 (at least on Windows, maybe one can compile by himself...),
but contains PHP 4.3.9 as an Apache module. I couldn't use it: some PHP modules that are required need at least PHP 5.0.
Solution was: return to Oracle HTTP Server from the 9i companion CD while running a 10gR2 database in a separate Oracle Home.

Categories