"Calling the undefined function sqlsrv_connect ()" when trying to connect to Azure DB from PHP

I am trying to connect from php to Azure DB using

$connectionInfo = array("UID" => "xxx@xxx", "pwd" => "xxx", "Database" => "xxx");
$serverName = "tcp:xxx.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);

But it gives me

Fatal error: call to undefined function sqlsrv_connect () in C: \ wamp \ www ... \ index.php on line 19

+5
source share
2 answers

you should use the native SQL Server driver for php in the first place, then you can do something like:

$serverName = "tcp:sample.database.windows.net, 1433";

$connectionOptions = array("Database" => "sampleInit", 

                           "UID" => "sampleUsr@sample",

                           "PWD" => "samplePass",

                           "MultipleActiveResultSets" => false);

$conn = sqlsrv_connect($serverName, $connectionOptions);

if($conn === false)

{

     die(print_r(sqlsrv_errors(), true));

}

You can learn more about PHP and SQL Azure on the following blog:
http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx

+8
source

dll ext/, extension=php_sqlsrv.dll php.ini php7/.

0

All Articles