2015-12-21 413 views
10

已經下載了微軟的SQLSRV ...此擴展需要Microsoft ODBC驅動程序11 SQL Server和SQL Server進行通信

enter image description here

,並在我的phpinfo()

enter image description here

enter image description here

啓用php.ini兩個C:\wamp\bin\apache\apache2.4.9\binC:\wamp\bin\php\php5.5.12 enter image description here

仍然有這樣的錯誤。

Failed to get DB handle: SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver 11 for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 

和我的代碼是

try { 
    $dbh = new PDO ("sqlsrv:Server=$host;Database=$db","$user","$pass"); 
    } catch (PDOException $e) { 
    echo "Failed to get DB handle: " . $e->getMessage() . "\n"; 
    exit; 
    } 
    $stmt = $dbh->prepare("select top 5 from teams"); 
    $stmt->execute(); 
    while ($row = $stmt->fetch()) { 
    print_r($row); 
    } 
    unset($dbh); unset($stmt); 
+0

「驅動程序11」。你有沒有檢查你實際安裝的版本?只有一個sqlserver驅動程序意味着什麼。 –

+0

@MarcB你是什麼意思?在哪裏檢查它? –

回答

相關問題