setting up PHP 7 to connect to SQL server 2014 - php

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.

Related

Sqlsrv dll does not properly load on IIS

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.

PHP with OCI8 Oracle connection on Windows 10 x64 and Windows Server 2008 x64

I am struggling with the setup of an Oracle database connection in Windows x64
My system:
Windows 10 x64 as client PC
Windows Server 2008 x64 as DBServer in the local network
PHP 7.2 TS Windows x64 installation Oracle Database
11.2 Oracle Database Client (present installation of 2014 do not now version, must be a x64 because it runs on server 64 bit)
Other Connections:
SQL Plus connection is working on server and on client PC SQL
Developer is connected to Database on server and works on client PC too.
Just the connection over PHP to the Database is making huge problems.
I know it is a x64 system so I installed the php 7.2 TS for windows x64.
I do not even come to connect to the Oracle Database Client... because the installation of the oci8.dll extension is failing.
What I did so far:
I uncommented the extentinos in the php.ini: OCI8.dll and the OCI8_11g.dll and put it into the php/ext directory.
I set an absolute path to the ext-folder in php.ini
When trying to load php in the command prompt with extention oci8 or oci8_11g enabled it says:
[path to the ext] not a Windows32 application or ...dll not found - but the directory is correct and the ddl-file is there.
I tried to set up an apache server from apachelounge build x64 and it is running. PHP7 is installed as an implemented apache module and the oci8 is enabled. But still it does give me the PHP warning message of [path to the ext] not ...dll not found.
I do not know what to do now. My windows 10 is a new installation. I did not change the system variables. PHP is just not taking the extesion.
You can find the phpinfo of my client PC uploaded as a screenshot here:
https://ibb.co/iPJ4W7
Any suggestions?
Thank you for your help.

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 5.4 & MSSQL - Wampserver

I am trying to update my PHP, MSSQL functions to the newer ones which are supported by PHP 5.4. I have done everything and searched everywhere but I just can't get it to work.
I have installed WampServer 32 Bit to my C: drive and I have installed SQL drivers for PHP. I have made sure that the package I chose was 3.0 (http://www.microsoft.com/en-gb/download/details.aspx?id=20098) and I installed them correctly. I put the 'php_sqlsrv_54_ts.dll' into the ext folder which is in wamp/bin/php/ext and I added the 'extension=php_sqlsrv_54_ts.dll' to the php.ini file which is in wamp/bin/php.
Next I started all the services successfully and then went to my local host to find out that I was receiving this error:
Call to undefined function sqlsrv_connect() in C:\wamp\www\launcher\Login2.php on line 11
Further Information:
Running Windows 7 SP1 Ultimate 64 bit
Download Wamp Server 2 for 32 Bit
Apache : 2.4.4
MySQL : 5.6.12
PHP : 5.4.16
PHPMyAdmin : 4.0.4
SqlBuddy : 1.3.3
XDebug : 2.2.3
Running it on my localhost/127.0.0.1
Using port 8080 in Apache
Enabled pdo extensions in php.
Using the php_sqlsrv_54_ts.dll
Restarted Wamp several times.
I fixed it. I had previously gone into PHP extension via wamp server controls and ticked php_pdo_mssql and php_mssql but now that I have unchecked these I don't get the error anymore but rather a database connect fail. I am not familiar with the new sql server connections. Before I used mssql_connect with my host being as 'Farbod-PC\SQLExpress' I still use this host and it works fine.
after spending 7 hours on it, this was the answer to connect PHP 5.4 to MS SQL server.
edit: or just use php 5.3, as that has native php mssql connectors

Categories