“Call to undefined function sqlsrv_connect()” when trying to connect to Azure DB from PHP

后端 未结 2 642
生来不讨喜
生来不讨喜 2020-12-02 02:05

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

$connectionInfo = array(\"UID\" => \"xxx@xxx\", \"pwd\" => \"xxx\", \"Database\" => \"xxx\");
$server         


        
相关标签:
2条回答
  • 2020-12-02 02:41

    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));
    
    }
    

    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

    0 讨论(0)
  • 2020-12-02 02:41

    I added this dll to the ext/ folder then added extension=php_sqlsrv.dll to the php.ini in the php7/ folder.

    0 讨论(0)
提交回复
热议问题