php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63312 Missing documentation
Submitted: 2012-10-19 13:47 UTC Modified: 2013-01-12 15:20 UTC
From: raul dot 3k at gmail dot com Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 5.3.18 OS: Windows
Private report: No CVE-ID: None
 [2012-10-19 13:47 UTC] raul dot 3k at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.sqlsrv-connect
---
I noticed that you don't really need to put the instance name in connection 
string.
In my case (SQL Server 2008 R2 on Windows Server 2008 as database server, using a 
php 5.3.14 and Windows Server 2003 with IIS 6.0 as web server), this function 
don't let me put the instance name at string connection. It throws an error: Error 
Locating Server/Instance Specified.

Test script:
---------------
<?php
// When I take the instance name off, it works.
$serverName = "192.168.0.11\SVDCBD01";
$connectionInfo = array( "Database"=>"CorporeRM", "UID"=>"planilha", "PWD"=>"planilha");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Expected result:
----------------
Connection established.

Actual result:
--------------
Array
(
    [0] => Array
        (
            [0] => 08001
            [SQLSTATE] => 08001
            [1] => -1
            [code] => -1
            [2] => [Microsoft][SQL Server Native Client 10.0]SQL Server Network 
Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
            [message] => [Microsoft][SQL Server Native Client 10.0]SQL Server 
Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
        )

    [1] => Array
        (
            [0] => HYT00
            [SQLSTATE] => HYT00
            [1] => 0
            [code] => 0
            [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout 
expired
            [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout 
expired
        )

    [2] => Array
        (
            [0] => 08001
            [SQLSTATE] => 08001
            [1] => -1
            [code] => -1
            [2] => [Microsoft][SQL Server Native Client 10.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 10.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.
        )

)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-12 05:09 UTC] frozenfire@php.net
-Status: Open +Status: Not a bug
 [2013-01-12 05:09 UTC] frozenfire@php.net
So far as I can tell, this is an issue with your connection parameters, as 
opposed to incorrect documentation.

If you can demonstrate that a modification of your $serverName parameter with the 
same essential information results in a successful connection, such that the 
documentation is incorrect, please do so.
 [2013-01-12 15:20 UTC] raul dot 3k at gmail dot com
I don't know how I can demonstrate it to you. But I just tested it again and I 
got the same error:
<?php
$serverName = "192.168.0.11";
$connectionInfo = array( "Database"=>"CorporeRM", "UID"=>"planilha", 
"PWD"=>"planilha");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Result:
Connection established.

With the serverName:
<?php
$serverName = "192.168.0.11\SVDCBD01";
$connectionInfo = array( "Database"=>"CorporeRM", "UID"=>"planilha", 
"PWD"=>"planilha");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

Result:
Connection could not be established.
Array
(
    [0] => Array
        (
            [0] => 08001
            [SQLSTATE] => 08001
            [1] => -1
            [code] => -1
            [2] => [Microsoft][SQL Server Native Client 10.0]SQL Server Network 
Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
            [message] => [Microsoft][SQL Server Native Client 10.0]SQL Server 
Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. 
        )

    [1] => Array
        (
            [0] => HYT00
            [SQLSTATE] => HYT00
            [1] => 0
            [code] => 0
            [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout 
expired
            [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout 
expired
        )

    [2] => Array
        (
            [0] => 08001
            [SQLSTATE] => 08001
            [1] => -1
            [code] => -1
            [2] => [Microsoft][SQL Server Native Client 10.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 10.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.
        )


I also took a screenshot of the server configuration and hosted on ImagesHack:
http://img829.imageshack.us/img829/5719/doct.jpg
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC