2015-01-12 51 views
0

我有一個php網站託管在1and1.com,但是當我連接到我們的本地服務器數據庫(windows server 2012和sql server 2012)時讓我沒有運氣,它給了我這個錯誤:如何將我託管的php網站連接到本地服務器上的SQL Server數據庫

Call to undefined function sqlsrv_connect() in dbconn.php on line 9. 

這裏是我的數據庫連接:

<?php 

    $serverName='xxx.xxx.00.xx'; //<-- should I include PORT here? 
    $connectionInfo=array(
        'Database'=>'DBName', 
        'UID'=>'userName', 
        "PWD"=>'Password'); 

    $conn = sqlsrv_connect($serverName,$connectionInfo); //<-- line 9 here 

    if($conn){ 
     //echo 'Connection Established!<br />'; 
    }else{ 
     //echo 'Connection Failed!<br />'; 
     die(print_r(sqlsrv_errors(),TRUE)); 
    } 

?> 

其實,我很困惑,使用什麼..想我應該用IIS這裏或其他程序b爲了發展,我用XAMPP來測試我的網站。

我是新的這種東西,所以如果你能爲我提供一些一步一步的文章,這是更多的讚賞。

在此先感謝!

回答

2

the manual

The SQLSRV extension requires that the Microsoft SQL Server 2012 Native Client be installed on the same computer that is running PHP.

驗證安裝在服務器上。

+0

是的,已安裝。 – Waelhi

+0

當我在我的網站上運行phpinfo時,我看到'sqlsrv'的PDO驅動程序未啓用。所以它必須首先啓用1and1? – Waelhi

+0

@ Unknownymous2是的。 –

相關問題