php accessing ms sql server - error

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Jan 01, 2019 6:44 pm

Tue Jan 01, 2019 6:46 pm

Hi, I was wondering if you can help please.

I'm a complete newbie to php and got tasked with moving our php app from mysql to sql server 2012.
My env is php 7.0.33 64bit TS running on windows 7, sql server 2012 running on windows.
Running app on localhost via netbeans.

I have downloaded "Microsoft Drivers for PHP for SQL Server" from ... erver-2017.
Tried 64 bit TS drivers from version 4 to 5.3, ie included them in my php.ini:

When I do phpinfo();, all is good - no errors.
So I assumed that sql server extensions loaded ok into php.

My problem is that when I try to open sql server connection, I'm getting this error:
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in ...

My code is:
$serverName = "XX.XX.X.XX, 1433";
$connectionInfo = array( "Database"=>"dbname", "UID"=>"username", "PWD"=>"password","ReturnDatesAsStrings"=>true);
$db_conn = sqlsrv_connect( $serverName, $connectionInfo);

Can you please point me to the right direction - what am I doing wrong? Are the versions ok?
Any help is much appreciated, thanks in advance.

Post Reply