Cannot connect to MS SQL Server

General discussion on Zend Studio
Post Reply
Posts: 1
Joined: Wed Dec 14, 2016 2:07 pm

Cannot connect to MS SQL Server

Post by rola7895 » Wed Dec 14, 2016 2:30 pm

I am new to Zend and PHP. I started today and tried to connect to one of my SQL Server Databases, fetch all rows from a table and display them.
I get the errorr 'Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in ...', though sqlsrv is shown in phpinfo and the studio-editor shows description and parameters of this function.

What I did:
* Installed xampp an Windows 7/32 Bit
* Installed Zend Studio 13.5 Trial
* On the welcome page selected MSSQL support and SQL Development Tools and restarted
* Installed php_sqlsrv_7_ts_x86.dll and php_pdo_sqlsrv_7_ts_x86.dll and added to php.ini
* Restarted apache
* Created new local PHP project with PHP Version 7.0
* Wrote some code into index.php
* Run index.php as CLI PHP Application

What am I doing wrong?

User avatar
Zend Global Support
Posts: 997
Joined: Sun Dec 14, 2008 9:48 am

Re: Cannot connect to MS SQL Server

Post by zvika » Thu Dec 15, 2016 3:54 pm

You need to debug on the web PHP (XAMPP in your setup) with Zend debugger / Xdebug, in order to get the additional extension reflected in Zend Studio session.
You can also add the SQL extensions to the Zend Studio PHP CLI environment (by editing the php.ini or using your own NEW PHP CLI runtime) - I never tried SQL through CLI but it might be supported as it can make TCP connections and use sockets.
Check phpinfo() in your debug session, not only in your XAMPP, if you use any other PHP runtime (Zend Studio internal PHP, or additional PHP you set up in PHP executables preferences).
Zvika Dror
Zend Support Team

Post Reply