读书人

php连接SQLSERVER 的连接串中实例名的

发布时间: 2012-03-13 11:21:11 作者: rapoo

php连接SQLSERVER 的连接串中实例名的问题

PHP code
 $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\t02

SQLSERVER 的实例名写在哪? 上面的写法通不过


[解决办法]
<?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');
}
?>

读书人网 >PHP

热点推荐