PHP - SQL Server 2005 express to 2008 standard problem - php

I have a PHP app running happily on the following system:
web app: PHP version 5.2.3
OS: Windows Server 2003 Standard 32 bit
database: SQL Server 2005 (express)
web server: IIS 6
I'm trying to get the same thing running on the following:
web app: PHP version 5.2.11
OS: Windows Server 2008 Standard 64 bit
database: SQL Server 2008 Standard 64-bit
web server: IIS 7
After doing the install and setup I usually do, phpinfo() is running but there is no MSSQL section. I've looked around and found some MS documentation to set up the system using a php_sqlsrv.dll and tried that but it seems to use a different interface to connect to the database (no more mssql_connect(), now it's sqlsrv_connect()). Is this the only way to connect php to SQL Server 2008 or do I just have the setup wrong? If I can go back to PHP 5.2.3 and have it work, that will be fine but I didn't want to undo what I have if it won't help.
Thanks,

There is an extensive tutorial on MSDN on how to do this.
http://msdn.microsoft.com/en-us/library/cc793139%28SQL.90%29.aspx

The extension named php_mssql.dll is linked with an old Microsoft library (ntwdblib.dll). This library was last updated with MS SQL Server 6.5. It's a 32 bit library and does not support many of the new features introduced in newer versions of the database. It is possible to compile a version of the extension using FreeTDS. That will give access to the latest version of the TDS protocol. This also allows you to access SQL Server from a Linux/Unix based system.
The extension named php_sqlsrv.dll is developed and maintained by Microsoft gives much better support for the newer versions of SQL server and it should work in both the environments you describe.

There should be a dll named php_mssql.dll in the ext folder of your php installation. You will want to make sure this is being loaded in your php.ini file with extension = php_mssql.dll . If that is not showing in phpinfo() after restarting the webserver it may be that you have installed the wrong thread safe version of PHP depending on how you've set things up with Fast CGI. You shouldn't have a problem using sqlsrv (SQL Server Driver for PHP). I would however recommend using version 1.1 of the driver as it has some improvements and supports SQL Azure. One thing you will notice is that datetime columns come back as PHP DateTime objects instead of strings. I've also noticed that you run into a lot less problems if you just install the stack with the Microsoft Web Platform Installer.

After having this issue and almost tearing my hair out for hours and giving up, I found the answer:
http://docs.moodle.org/22/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows
php_dblib.dll is the "new" dll that supports the old mssql php functions (mssql_connect() etc). So basically this new dll replaces php_mssql.dll and everything just works as it did before. (Well it does for me now)
My server setup is:
O/S: Windows Server 2008,
DB: MSSQL Server 2008 R2,
PHP: 5.3.13
Excerpt from phpinfo():
System Windows NT XXXXXXXXXXXXX 6.1 build 7601 (Windows Server 2008 R2
Enterprise Edition Service Pack 1) i586 Build Date May 8 2012 18:41:52
Compiler MSVC9 (Visual C++ 2008) Architecture x86
Configure Command cscript /nologo configure.js
"--enable-snapshot-build" "--enable-debug-pack" "--disable-zts"
"--disable-isapi" "--disable-nsapi" "--without-mssql"
"--without-pdo-mssql" "--without-pi3web"
"--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared"
"--with-enchant=shared" "--enable-object-out-dir=../obj/"
"--enable-com-dotnet" "--with-mcrypt=static"
"--disable-static-analyze"
Server API CGI/FastCGI
Virtual Directory Support disabled
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\Program Files (x86)\PHP\v5.3\php.ini
Hope this saves someone some time.

Related

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.

Configure PHP to work with MSSQL by using SQLSRV

I'm trying to configure PHP to work with MSSQL database. I found some instructions on the internet, but I didn't succeed.
I'm using php 5.3, MS SQL 2008, server is Openserver 5.2.2, OS is Windows 8.1.
I installed MS SQL Management studio 2008.
I installed ODBC driver
I installed SQLSRV version 53_ts_vc9 (from phpinfo() (vession - 5.3,
thread safe, compiler - MSVC9))
I've added extension=php_sqlsrv_53_ts_vc9.dll line to php.ini
I've rebooted server and got "--without-mssql" "--without-pdo-mssql"
in phpInfo()
Help me, guys. What have I done wrong?
I've rebooted server and got "--without-mssql" "--without-pdo-mssql"
in phpInfo()
Those are compile time options, not configuration options. You need to compile php from source, or get a module that provides that functionality.

Configuration Issues with SQLSRV for PHP for MSSQL

I am installing a configuration with WampServer 2.4:
- Windows 7 64-bit sp1
- WampServer 2.4 64-bit
- PHP 5.4.3 64-bit (came with the WampServer)
- Apache 2.4.4
- Microsoft SQL Server 2012 Native Client 64-bit
- Microsoft SQLSRV 3.0 (php_sqlsrv_54_ts.dll, php_pdo_sqlsrv_54_ts.dll and they are put in c:/wamp/bin/php/php5.4.3/ext/
And I edited the C:\wamp\bin\apache\Apache2.4.4\bin\php.ini with the lines:
- extension_dir = "c:/wamp/bin/php/php5.4.3/ext/"
- extension=php_sqlsrv_54_ts.dll
- extension=php_pdo_sqlsrv_54_ts.dll
And I restarted all the services from Wamp.
But I still couldn't see the SQLSRV section from phpinfo -- and of course my connection test program failed.
What might have gone wrong?
Can anyone help?
Your issue is because you are using (or WAMP has given you) 64bit php, where as your sqlsrv driver is most likely 32bit.
Your solution is to switch to a 32bit version of php (The benefits of running in 64, are pretty much non existent anyway unless you need larger data types), or to recompile the sqlsrv driver in 64bit (Likely more trouble than it is worth).
Try a WAMP 32 bit version. http://www.wampserver.com/en/#wampserver-32-bits-php-5-4
Also if Apache and my-sql are of no consequence to you (they are just a web sever and and an sql database) you can install a WISP PHP Stack in a breeze using the web platform installer. http://www.microsoft.com/web/downloads/platform.aspx
For those of you using a 64bit version of PHP, the unofficial dll files linked below will work:
http://robsphp.blogspot.co.uk/2012/06/unofficial-microsoft-sql-server-driver.html
I am using 64bit WAMP on a 64bit Windows Server and was about to call it quits before I found those DLL files. It's odd that the official DLLs don't work with 64bit PHP, but I'm glad I at least found a solution.
I'm using just Apache 2.2 and PHP 5.4 in 32bit with SQLSRV 3.0 and it is now working. Note that the Thread Safe is set to Yes, thus SQLSRV ts.dlls should be used. It was a struggle. Hope this helps others.

'Error!: could not find driver' after installing php_[pdo_]mssql.dll on WampServer

Similar questions seem to be all over the internet, but so far nothing has helped.
I'm currently running WampServer with Apache 2.4.4 and PHP 5.4.12 on Windows Server 2008 R2. According to the PHP documentation the drivers necessary to connect to an MSSQL server ship with the distribution; they do not. Neither php_mssql.dll (which the documentation claims is no longer necessary for PHP5.4, but which is still referenced in php.ini. Who knows) nor php_pdo_mssql.dll are present in the distribution.
Several sources pointed to these drivers from Microsoft, however I had no success either renaming the respective drivers to php_mssql.dll/php_pdo_mssql.dll or keeping the names the same (php_sqlsrv_54_nts.dll, php_pdo_sqlsrv_54_ts.dll, etc.) and modifying php.ini to point to the proper driver. Though I didn't get an error upon starting apache as I do when the driver is simply missing, I received Error!: could not find driver when attempting to point to a test php page at localhost.
This article seemed the most promising, but unfortunately ntwdblib.dll is not included in the zip distributions of PHP, contrary to what the article claims. This seems like it should be a laughably simple problem: missing drivers, which are supposedly readily available. And yet here I am... What am I doing wrong?
In case anyone else ends up here while trying to solve this problem, here are the steps that have worked for me the two times I've done it. These steps worked both on Windows Server 2008 R2 and Windows 8.
For my purposes, I used the latest 32-bit (x86) version of WampServer (at the time of this writing, it was 2.4, and came with Apache 2.4.4 and PHP 5.4.16). The 32-bit version is necessary, as the drivers are 32-bit; the 64-bit version will not work.
Install Microsoft Visual C++ 2010 Redistributable Package x86
Install Microsoft SQL Server 2008 Native Client x86 (Click "Download" and select ENU\x86\sqlncli.msi. Once again, the 64-bit version will not work)
Install Microsoft ODBC Driver 11 x86 (Click "Download" and select 1033\x86\msodbcsql.msi)
Install Microsoft SQLSRV driver 3.0 in php/ext/ (For my installation, this was C:/wamp/bin/php/php5.4.16/ext/)
Edit Apache's php.ini to include the line extension=php_pdo_sqlsrv_54_ts.dll (for my installation, this was located in C:/wamp/bin/apache/Apache2.4.4/bin/)
You have to place the file in the directory for PHP/ext (bin/php/ext depending on your Wamp / Xampp installation). However, you also need the SQL server native client as per: http://msdn.microsoft.com/en-us/library/cc296170.aspx

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