php5.5用PDO连接sql-server2008R2无法连接

$dbName = "sqlsrv:Server=localhost;Database=YTHIIS";
用localhost可以连接,用计算机名也可以连接(但只限本地)

$dbName = "sqlsrv:Server=127.0.0.1;Database=YTHIIS";
用127.0.0.1无法连接,192.168.2.118局域网IP也无法连接,局域网计算机名也无法连接。

 <?php
 try {
    $dbName = "sqlsrv:Server=localhost;Database=YTHIIS";
    $dbUser = "sa";
    $dbPassword = "sa123";
    $db = new PDO($dbName, $dbUser, $dbPassword);
    if ($db) {
        echo "<b style='color: green'>Database connect succeed.</b><br />";
    }
}
catch (PDOException $e) {
    $content = iconv("UTF-8","gbk",$e->getMessage());
    echo   $content . "<br />";
    echo "Hello World!";
}

 ?>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问