0

Xampp を Php 5.4 (Zend studio) で使用しており、php 5.4 用の sqlserver driver download V3.0 をダウンロードしています。

この URLをたどりました。

上記の URL のすべての手順を構成しましたが、それでも接続を開くことができず、エラーが発生しました..

Connection could not be established.

Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. [message] => [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 11.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct enter code here and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ))

上記の問題の解決策を教えてください。

4

2 に答える 2

0

(古い投稿を復活させるつもりはありませんが、他の人が答えを探している場合に備えて、検索中にこの投稿が出てきたので...)

ネイティブ ドライバーを使用して XAMPP 上の PHP から SQL_server に接続するための簡単なステップ バイ ステップ ガイド:

  1. まず、http://www.microsoft.com/en-us/download/details.aspx? id=20098 から SQL_server Microsoft ネイティブ ドライバー用の PHP をダウンロードします。セットアップに適したものを慎重に選択してください。

  2. PHP 拡張ディレクトリ (通常はc:\xampp\php\ext) にインストールします。

  3. PHP.ini(通常はC:\xampp\php) で、行のコメントを外すか追加して (選択したドライバーのバージョンに応じて) 、新しい拡張機能を構成します。すなわち:

    extension = php_sqlsrv_55_ts.dll
    
  4. XAMPP コントロール パネルから Apache を再起動します (停止 + 開始)。

    これで、PHP セットアップが SQL_server データベースに接続できるようになりました。次のコードを調整して、独自のデータベースでテストします。

    <?php
    $server = "SERVER\SQLEXPRESS";
    $database = "test_database";
    $user = "test_user";
    $pwd = "test_password";
    
    $options = array(  "UID" => $user,  "PWD" => $pwd,  "Database" => $database);
    $conn = sqlsrv_connect($server, $options);
    
    if ($conn === false) {
        die("<pre>".print_r(sqlsrv_errors(), true));
    }
    echo "Successfully connected!";
    
    $sql = "SELECT TOP 50 * FROM dbo.table_name";
    $query = sqlsrv_query($conn, $sql);
    if ($query === false) {
        exit("<pre>".print_r(sqlsrv_errors(), true));
    }
    
    while ($row = sqlsrv_fetch_array($query))  {
        echo "<p>$row[field1] $row[field2]</p>";
    }
    
    sqlsrv_free_stmt($query);
    sqlsrv_close($conn);
    

SQL_server 2008 R2 および SQL_server 2014 Express で XAMPP 3.2.1 および XAMPP 5.6.14 からテスト済み。

于 2016-04-07T15:25:42.180 に答える
0

スタート \ Microsoft SQL Server 2008 \ Configuration Tools \ SQL Server Configuration Manager に移動し、次に SQL Native Client Configuration、Client Protocols に移動して、共有メモリ、tcp/ip、および名前付きパイプが有効になっていることを確認します。

まだコメントできないので、これを回答として書いています。

于 2013-07-24T11:10:52.923 に答える