Sqlsrv dll does not properly load on IIS - php

I am using PHP 7.3 and trying to run sqlsrv but I cannot get my PHP environment to load sqlsrv. I look at the phpinfo and the extension does not show up. These are the steps I have taken.
Through the Web Platform Installer, I have installed PHP 7.3 for IIS, the SQL Server Driver, and the Windows Cache Extension.
I have put php_sqlsrv_73_nts_x64.dll in the extension directory.
I have verified my php.ini configurations.
Downloaded and installed the latest Microsoft ODBC driver.

Found the bug. Turns out I was had installed the SQL Server Driver for IIS when I really needed the SQL Server Driver for IIS Express.

Related

Call to undefined function ocilogon() - IIS 7.5 - Windows 2008 R2 x64 - PHP 7.2.7

I am migrating a website from a development environment (Angular 4 - WAMP Server - PHP 5.6.35) to a production environment. In development, the Angular 4 application was successfully able to connect to a PHP script and run an Oracle stored procedure so there are no issues with the code.
In production, I've had to install PHP using the Web Platform Installer to successfully run a PHP site with phpinfo() showing 'PHP Version 7.2.7'. I run the application and when it attempts to run the PHP script, I get a 500 Internal Server error when the script is run. PHP error logs show:
<b>Fatal error</b>: Call to undefined function ocilogon() in <b>C:\inetpub\wwwroot\app\assets\scripts\php\pullData.php</b> on line <b>154</b><br />
Research has indicated that the issue could be:
Possible IIS configuration issue
Oracle Instant Client issue
OCI8 PHP Library not enabled
I think I've ruled out the IIS configuration as the front-end connects to PHP and runs the scripts without issue.
Oracle Instant Client 12.1 is installed and other applications can connect to Oracle. The PATH environment variable appears correctly set. I don't know if it is a 32-bit or 64-bit version - or whether this makes a difference.
I think this is the issue - the OCI8 library isn't enabled correctly. On the dev server, I was able to modify the php.ini file to uncomment (and enable) the dll, and phpinfo() showed the OCI8 library in the list:
extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
On production, I've had to manually add the 'extension=php_oci8_12c.dll' line (it wasn't uncommented out) and I've checked the EXT folder of PHP and the dll exists there. Phpinfo() still doesn't show the OCI8 library enabled.
Issue is fixed, and I took the following steps to fix it:
Uninstalled PHP (removed all PATH references and folders).
Uninstalled Oracle Instant Client using Oracle Universal Installer.
Installed PHP for IIS Express (and all dependencies) using the IIS Web Platform Installer.
Installed Oracle Instant Client 12c using automatic installer (winx64_12102_client.zip), not ZIP file. This way I didn't have to manually add PATH variables etc.
Checked PHP version (and if it was thread safe) using phpinfo(). Thread safety was (is) disabled. Downloaded the non-thread-safe (nts) version of php_oci8_12c.dll from windows.php.net (https://windows.php.net/downloads/pecl/releases/oci8/2.1.8/) and copied contents to EXT folder in the PHP install directory (which was in a parent folder of IIS Express).
Edited the PHP.ini files (php.ini-production and php.ini-development and php.ini) to include 'extension=php_oci8_12c.dll' or uncomment "extension=oci8_12c".
Restarted the server (probably unnecessary).
Opened CMD and ran the code 'php --ri oci8' to check OCI8 support is enabled and using the version of Oracle Instant Client that I just installed. Verified this also by using phpinfo().
Done. OCI functions now work.
This was a grueling process because this web server had multiple installs of Oracle Instant Client and the Web Platform Installer for IIS was buggy when installing PHP 5.6 and its dependencies. I was lucky that this time that the installer did not error out with PHP 7.2 as it originally did when installing PHP 5.6.

setting up PHP 7 to connect to SQL server 2014

I have both a development PC and windows server that run PHP. I'm trying to configure them for SQL server. I've downloaded SQL Server 2014 express and it's running on both.
The Development box box: 64-bit windows 7 PC, running IIS 7.5 and PHP 7.1.3
The server is 64-bit windows server 2008 running PHP version 7.1.3
I've started with the dev box and tried downloading the drivers and modifying the php.ini to add the extension.
The drivers is not loading when I run phpinfo(). With some further research, I think I have not got the correct version of the driver for my dev box. I'm currently using php_sqlsrv_54_ts.dll as my extension, but the installation media for the driver came with several .dll files and I'm not sure I have the right one. I did notice that the installation file I downloaded was SQLSRV30.EXE. I also noticed that there was SQLSRV52.EXE, but that does not support win 7. Can someone point me to the correct driver for my dev box and server.
I'm getting so frustrated with this because it's not self explanatory.
It turns out that there are no SQL drivers for PHP 7.2 that work under windows 7. I had to downgrade to PHP 7.1 and then the drivers loaded and worked.

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

install Microsoft Drivers for PHP for SQL Server on Windows 8

Does Windows 8 supports sql server driver for php.
I found that system Requirements for sql Driver does not contain Windows 8.
I installed and configured sql driver for php on wamp server, but sqlsrv doesn't show in phpinfo().
It's working fine for me on windows 8, if you don't activate the good extension in php.ini, by default (int XAMP) the slqsrv extension is selected extension=php_pdo_sqlsrv.dll, in my case, I am using PHP 5.4 and have configured the following extension:
extension=php_pdo_sqlsrv_54_ts.dll
See Readme file provided with the installation drivers to see which extension to activate in your case.
Restart the server and it's done.

Installing MSSql Server 2008 Driver for PHP

I have installed Microsoft driver SQLSrv 3.0, installed it, gave the path to php extentions folder. Changed the Php.ini file to include the code
extensions=php_sqlsrv_53_nts_vc9.dll
But when i tried to check whether the drivers loaded by the phpinfo method, The info page doesnot include Sqlsrv section.
I m using Wamp server and windows 7.. php 5.3.6
It means drivers are not loaded. What can be the possible error . Any body help
SQLSRV 3.0 has the Microsoft Native Client 11 as a dependency. This is available for free from Microsoft. (It is also installed when you install SQL Server 2012.)
Try installing SQLSRV 3.0 using the Microsoft Web Platform Installer; that will probably address all of the dependencies for you.

Categories