“调用未定义的函数 sqlsrv_connect()"尝试从 PHP 连接到 Azure DB 时 [英] "Call to undefined function sqlsrv_connect()" when trying to connect to Azure DB from PHP

查看:27
本文介绍了“调用未定义的函数 sqlsrv_connect()"尝试从 PHP 连接到 Azure DB 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下方式从 php 连接到 Azure DB

I'm trying to connect from php to Azure DB by

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

但它给了我

致命错误:在第 19 行调用 C:wampwww...index.php 中未定义的函数 sqlsrv_connect()

推荐答案

你必须使用用于 php 的 SQL Server 本地驱动程序,然后您可以执行以下操作:

you have to use the SQL Server native driver for php at 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));

}

您可以在以下博客文章中阅读有关 PHP 和 SQL Azure 的更多信息:
http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx

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

这篇关于“调用未定义的函数 sqlsrv_connect()"尝试从 PHP 连接到 Azure DB 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆