"调用未定义功能sqlsrv_connect()"试图从PHP连接到Azure的DB时 [英] "Call to undefined function sqlsrv_connect()" when trying to connect to Azure DB from PHP
问题描述
我想从PHP天青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);
但它给了我
致命错误:调用在C未定义功能sqlsrv_connect():\\ WAMP \\ WWW \\ index.php文件第19行
推荐答案
您必须使用的在首位的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的:结果
<一href=\"http://blogs.msdn.com/b/brian_swan/archive/2010/02/12/getting-started-with-php-and-sql-azure.aspx\">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
这篇关于&QUOT;调用未定义功能sqlsrv_connect()&QUOT;试图从PHP连接到Azure的DB时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!