$host='192.168.1.122';  --IP
$port=1433; --端口
$instanse = 't02'; --实例名
$username='sa';
$password='passss';
if (! $link = mssql_connect($host.':'.$port.$instanse, $username, $password) ) --这样写好像不对122的这台SQLSERVER上有多个实例。现在不想连接默认实例,而想连接T02实例在SSMS 里写法是  192.168.1.122,1433\t02SQLSERVER 的实例名写在哪? 上面的写法通不过

解决方案 »

  1.   

    $server = 'KALLESPC\SQLEXPRESS'; 这个格式的
      

  2.   

    <?php
    // Server in the this format: <computer>\<instance name> or 
    // <server>,<port> when using a non default port number
    $server = 'KALLESPC\SQLEXPRESS';// Connect to MSSQL
    $link = mssql_connect($server, 'sa', 'phpfi');if (!$link) {
        die('Something went wrong while connecting to MSSQL');
    }
    ?>
      

  3.   

    $host='192.168.1.122';  --IP
    $port=1499; --端口
    $instanse = 't02'; --实例名
    $username='sa';
    $password='passss';
    if ( $instanse == '')
    {
                    $hoststr = $host.':'.$port;
    }
    else{                $hoststr = $host.$instanse;
    }#       echo $hoststr;
                    if (! $link = mssql_connect($hoststr, $username, $password) )
                            return;
    heyli,你好,我用你的方法,确实可以连接实例名了,又出来一个新问题,连接实例名,自定义端口就不能用了。现在的解决办法如下:
    $host='192.168.1.122';  --IP
    $port=1499; --端口
    $instanse = 't02'; --实例名
    $username='sa';
    $password='passss';
    if ( $instanse == '')
    {
                    $hoststr = $host.':'.$port;
    }
    else{                $hoststr = $host.$instanse;
    }#       echo $hoststr;
                    if (! $link = mssql_connect($hoststr, $username, $password) )
                            return;
    能不能自定义端口,自定义实例名都带上的?
      

  4.   

    因为有一部分服务器是 自定义端口的, 另外一部分服务器是自定义实例名的,还有一部分服务器的SQL端口和实例名都是自定义的(当初出于安全等等原因) 总之不统一。现在在CACTI中需要监控它们的参数 。想用一个PHP脚本连上所有的服务器