SQLSRV Overriding Website Output in IIS 7/PHP 5.4 - php

I have a simple setup of IIS 7 with PHP 5.4. Everything has been working fine until I needed to add MS SQL Server support. I downloaded the SQLSRV package provided through this link, extracted the appropriate DLLs to my PHP ext directory and added the extension entry/configuration in php.ini like so:
; MS SQL Server
extension=php_sqlsrv.dll
;extension=php_pdo_sqlsrv.dll
[sqlsrv]
sqlsrv.LogSubsystems=-1
sqlsrv.LogSeverity=-1
sqlsrv.WarningsReturnAsErrors=0
... with an additional change to the extension_dir setting:
extension_dir = "ext"
..., and restarted my server. Now, when I run any request, I get:
PHP_RINIT for php_sqlsrv: entering
sqlsrv.WarningsReturnAsErrors = Off
sqlsrv.LogSeverity = -1
sqlsrv.LogSubsystems = -1
sqlsrv.ClientBufferMaxKBSize = 10240
PHP_RSHUTDOWN for php_sqlsrv: entering
Sometimes, the first line is missing, but it's generally the same problem. No page is generating proper text/HTML anymore! What has happened? Thanks.

On the balance of probability, I imagine you're using the wrong sqlsrv dll. First things first: did you download SQLSRV from here?
I'll assume you want the PDO version (I use it; it works very well!). From the file name, I can't tell what you have, but for your circumstances you should should be using php_pdo_sqlsrv_54_nts.dll. As you're using IIS, you'll have an NTS version of PHP, which should be used with non thread safe extensions.
Try replacing the dll you're using with that one, and reload the application pool in IIS. phpinfo() should show sqlsrv as an available PDO driver. Let me know how you get on... :)

Related

Using php 7.3.4 64bit with a 64bit oracle client and php 7.3.4 32bit with a 32bit oracle client on the same server

We have an IIS on our Windows Server 2016 Standard which use via fast cgi a php 7.3.4 32bit.
To build a connection to a oracle 12cR1 database on another server we use the php_oci8_12c.dll and the oracle client 12.1.0 32bit.
This works fantastic. Now we want to switch to php 64bit, but for some old projects we still need the 32bit php and oracle client.
So we do the follow:
1. Uninstall the oracle client
2. Install oracle client 12.1.0 64 bit (install type: administration) in C:\Oracle\product\12.1.0\client_x64
3. Restart server
4. Configure the net manager
5. Install oracle client 12.1.0 32 bit (install type: administration) in C:\Oracle\product\12.1.0\client_x86
4. Restart server
5. Configure the net manager
6. Download php 7.3.4 64 bit with the 64 bit extensions
Now we have two php folders:
C:\php7_3_4_x86
C:\php7_3_4_x64
At this time the IIS use the C:\php7_3_4_x86\php-cgi.exe and the 32bit oracle client, because its the latest installed client and the path is the first of all paths in the PATH variable.
Now we want to switch temporary to 64bit. So we try the follow steps:
1. Change in IIS handler to C:\php7_3_4_x64\php-cgi.exe
2. Swap the oracle clients path in the environment variable PATH. Now its: C:\Oracle\product\12.1.0\client_x64;C:\Oracle\product\12.1.0\client_x86;[...]
3. Restart the server
After restart we try to open a php file in browser, but we get the follow error:
Call to undefined function oci_connect
If we put the oci.dll from C:\Oracle\product\12.1.0\client_x64\BIN directly into the C:\php7_3_4_x64 it loads the file. So we think it cannot find the 64bit client.
We also try the method with create a link in C:\Windows\system32 / SYSWOW64, but this doesnt work. Same error.
What could we do? We need the possibility to switch between 32&64bit php+oracle.
Problem solved.
Everything was correctly, but the oracle setup forgot the correct windows right for the clientx64 folder.
At the clientx86 the group "authenticated user" (in german: Authentifizierter Benutzer) has full access, while the clientx64 doesnt have this group.
After adding the group and give it full access to the clientx64 folder it works. It isn't necessary to switch the entries in the PATH variable. PHP try to loading the first element and after failing it loads the second element in PATH variable.
So everything works!

Debugging PHP codes

I am following this tutorial
STEPS
Downloaded Xdebug - PHP VC 11 64 bit [Didn't download TS version - ]
My php is 5.6.11 vc 11
Added zend extensions with right dll path
Started server. Zend extension is added. Checked with phpinfo()
Downloaded Eclipse PDT
Opened Eclipse and created new project and given path to my files
Localhost server so didn't change PHP->Servers
Debug configurations
Changed server to XDebug
Added a file to debug
Started the server. It opens in mozilla [I changed default web browser to mozilla in eclipse]
But it didn't stop at my breakpoints
<?php
$x = 2;
$y = 5;
$z = $x + $y;
echo $z;
?>
Did I miss any step? Or is there any other way to achieve debugging PHP?
Any Suggestions?
Make sure you have the correct version of the XDEBUG dll to match your Apache/PHP installation.
If you have PHP installed as an Apache module you need the Thread Safe XDEBUG dll. If you have PHP installed as CGI/FastCGI then you want the Non Thread Safe XDEBUG dll.
Its a good idea to use the XDEBUG Wizard
That will tell you exactly what to modify in your php.ini and which dll you should download.
Beware of old tutorials, they may suggest using the old and now defunct zend_extension_ts= when you should use zend_extension=
Also on windows systems use the unix forward slash and not the dos backslash in the path to the XDEBUG dll like so :-
zend_extension="C:/server/php/ext/php_xdebug-2.3.3-5.6-vc11-x86_64.dll"

Using Cassandra PDO Driver on Windows

Is there any way to have Cassandra PDO at Windows with Wamp?
This is for development purposes I don't want to install Linux and change all the environment.
https://code.google.com/a/apache-extras.org/p/cassandra-pdo/
I'm using Windows 7 (64 Bit), Wamp 2.5, PHP 5.5.
OK, here's what I found out:
1) It's totally possible
2) The docs that appear in the first google search results are a bit obsolete
Start by downloading the latest Datastax Community Cassandra here:
http://planetcassandra.org/cassandra/
Install & setup properly. In fact, most of the configuration is done by the installer, you just have to edit the apache-cassandra/conf/cassandra.yaml file to find all paths to /var/lib... and change those into something like d:/cassandra/... That includes "commitlog", "data", "saved_caches". Restart the Cassandra service, examine the logs. Mine shown no problem. The OpsCenter at ...:8888/opscenter/index.html was working fine, showing one node online.
Now, the PHP part.
There's a sneaky thing called Thrift. From what I've learned today (I first heard about Cassandra and Thrift yesterday), it's a way describe a binary protocol of connecting to some online service, in this case, to Cassandra. It will basically generate PHP files that will provide all the connectivity you need from PHP itself (no extensions needed).
You will need:
1) The Thrift PHP libs
2) The .exe Thrift compiler
Both can be downloaded here:
https://thrift.apache.org/download
Then use the following command to compile PHP files that will act as a "driver" to connect your PHP applications to Cassandra:
thrift --gen php D:\DataStaxCommunity\apache-cassandra\interface\cassandra.thrift
Put the result in some PHP include_path folder.
Also, find the PHP Thrift libs (in the libs archive from the same download page) and put those in a folder accessible to your script (e.g. include_path or the project folder).
Refer this page:
thrift.apache.org/lib/php
I guess that should help!
I have same problem as you, but when i tried this method, it works correctly for me.
Reference link
Here is a code example, very easy to understand :
<?php
require_once 'Cassandra/Cassandra.php';
$o_cassandra = new Cassandra();
$s_server_host = '127.0.0.1'; // Localhost
$i_server_port = 9042;
$s_server_username = ''; // We don't use username
$s_server_password = ''; // We don't use password
$s_server_keyspace = 'cassandra_tests';
$o_cassandra->connect($s_server_host, $s_server_username, $s_server_password, $s_server_keyspace, $i_server_port);
$s_cql = "CREATE TABLE carles_test_table (s_thekey text, s_column1 text, s_column2 text,PRIMARY KEY (s_thekey));";
$st_results = $o_cassandra->query($s_cql);

Why does the connection to ASE fail when password encryption is required?

How can I password encrypt the database server connections from PHP to Sybase ASE?
The PHP connection to ASE fails when net password encryption reqd = 1.
How can we make a PHP DB connection to ASE with password encryption? Is there a PHP keyword or parameter that we need to set on the client side connection?
Below is a solution to this problem in term of able to connect from a Linux 64 bit base machine with PHP version 5.3.6 and Sybase driver from Sybase CTISQL Utility/15.7/P-EBF19975 ESD #3/DRV.15.7.0.3. While we got this to work, we need to have Apache to work in addition to this, I am hoping Sybase support is able to help us with that as well as they have with solution below to our question. I am posting this here for everyone benefit. Note: AFAICT, this is not a supported solution by Sybase. Please use it as your own risk.
Few things need to happen for this to work:
I've use the latest Debian Stable 6.05 squeeze 64 bit
I've install ebf19977(developer kit with open client, yes the number is off, that's not a mistake, you will see when you install it) downloaded from Sybase
Download PHP 5.3.6 from php.net website to be compile from source.
Step 1) I am assume one should easily set this up. Make sure you have sudo access
Step 2) To install the developer kit you need to type the whole path to where the setup.bin file is locate like so type in sudo /home/btran/ebf19977/setup.bin , this will start the setup, pretty much follow instructions there to to install OpenClient and its associate tools. Make sure that Open Client, and PHP library are install.
Once you done the install there are a few other steps to do:
Set all Sybase environments variables by executing the SYBASE.sh in the root directory at /opt/sybase
sudo cat /opt/sybase/SYBASE.sh >> /etc/profile , if necessary source /etc/profile
This will set most of the variables, but you need to add a couple variable that is not there:
PHPRC=/opt/sybase/OCS-15_0/config
LD_LIBRARY_PATH=/opt/sybase/OCS-15_0/php/php536_64/lib:/opt/sybase/OCS-15_0/lib
Your /ect/profile should look something like this:
# ------------------------------------
# Sybase Product Environment variables
# ------------------------------------
SYBASE="/opt/sybase"
export SYBASE
SYBASE_OCS="OCS-15_0"
export SYBASE_OCS
INCLUDE="/opt/sybase/OCS-15_0/include":$INCLUDE
export INCLUDE
LIB="/opt/sybase/OCS-15_0/lib":$LIB
export LIB
PATH="/opt/sybase/OCS-15_0/bin":$PATH
export PATH
LD_LIBRARY_PATH="/opt/sybase/OCS-15_0/php/php536_64/lib:/opt/sybase/OCS-15_0/lib:/opt/sybase/OCS-15_0/lib3p64:/opt/sybase/OCS-15_0/lib3p":$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PHPRC="/opt/sybase/OCS-15_0/config"
export PHPRC
JAVA_HOME="/opt/sybase/jre32"
export JAVA_HOME
RIBO_HOME="/opt/sybase/jutils-3_0/ribo"
export RIBO_HOME
# ------------------------------------
Then, you will also need to made modification to the interfaces file located at root directory /opt/sybase to look something like this, please do not use this, use your info:
dev
master tcp ether dev.company.com 4425
query tcp ether dev.company.com 4425
prod
master tcp ether prod.company.com 4425
query tcp ether prod.company.com 4425
ribo
master tcp ether testhost.company.com 5005
query tcp ether testhost.company.com 5005
You will also need to made modification to the ocs.cfg to get PHP to initiated correctly, this located in the folder /opt/sybase/OCS-15_0/config to look like this:
;;;;;;;;;;;
; This is the default external configuration definition file. Feel free
; to add your own customizations.
;
[DEFAULT]
; This is the default section loaded by applications that use
CS_SEC_ENCRYPTION = CS_TRUE
[ANSI_ESQL]
; This section defines configuration which an ANSI conforming
CS_CAP_RESPONSE = CS_RES_NOSTRIPBLANKS
CS_EXTRA_INF = CS_TRUE
CS_ANSI_BINDS = CS_TRUE
CS_OPT_ANSINULL = CS_TRUE
CS_OPT_ANSIPERM = CS_TRUE
CS_OPT_STR_RTRUNC = CS_TRUE
CS_OPT_ARITHABORT = CS_FALSE
CS_OPT_TRUNCIGNORE = CS_TRUE
CS_OPT_ARITHIGNORE = CS_FALSE
CS_OPT_ISOLATION = CS_OPT_LEVEL3
CS_OPT_CHAINXACTS = CS_TRUE
CS_OPT_CURCLOSEONXACT = CS_TRUE
CS_OPT_QUOTED_IDENT = CS_TRUE
; End of default sections
[isql]
CS_SEC_ENCRYPTION = CS_TRUE
[PHP]
CS_SEC_ENCRYPTION = CS_TRUE
; This is a sample section showing how you might alter configuration
; properties for you Embedded SQL application.
[SAMPLE_ESQL]
; use most of the ANSI properties defined above
include = ANSI_ESQL
; but override some default properties
CS_OPT_CHAINXACTS = CS_FALSE ; run in autocommit mode
;;;;;;;;;
Note: Very Critical to check for the existence of the php.ini file in the same directory as well /opt/sybase/OCS-15_0/config (this pointing the exention file, look at the environment variable LD_LIBRARY_PATH="/opt/sybase/OCS-15_0/php/php536_64/lib)
you php.ini should read like this:
extension=/opt/sybase/OCS-15_0/php/php536_64/lib/sybaseasephp.so
Step 3) compile PHP from source, again Sybase call for 64 bit.
I down load the source to /opt/php-5.3.6 for persistent with where most app install for Linux.
cd to /opt/php-5.3.6
./configure
VERY IMPORTANT to note, this is where we ran into a snag, if I choose any other configure option and not default ./configure, PHP will fail to load with error below:
btran#sls-baonix:/opt/php-5.3.6$ php ~/test-dev.php
PHP Warning: PHP Startup: Unable to load dynamic library
'/opt/sybase/OCS-15_0/php/php536_64/lib/sybaseasephp.so' -
/opt/sybase/OCS-15_0/php/php536_64/lib/sybaseasephp.so: undefined
symbol: executor_globals in Unknown on line 0
Fatal error: Call to undefined function sybase_connect() in
/home/btran/test-dev.php on line 10
]
Reason we need other options is we need it also to work with Apache. We got it now to work with PHP, but we need to be able to initiate PHP from website so the dependencies is that PHP beside support Sybase, it also need to support Apache. If any PHP expert out there has solution to this please jump in and help us out.

wamp php CLI has stopped working

I installed wamp server 2.2 with php 5.3.10 and apache 2.2.21. But when I want to execute some symfony command the response from my Windows 7 Home Premium is:
php -> CLI has stopped working
I had this error for a long time. It turned out I was on a slightly older version of Xdebug (php_xdebug-2.2.0-5.4-vc9.dll).
I replaced that file with "php_xdebug-2.2.2-5.4-vc9.dll" and it magically started working immediately.
I'm on wamp, and I updated both php.ini files (one is for cli, one for normal use) with the latest filename.
"zend_extension = c:\wamp\bin\php\php5.4.3\ext\php_xdebug-2.2.2-5.4-vc9.dll"
Then dropped the new file into the php ext folder and instant success. Hope this helps.

Categories