"fff","Connect">
当前位置:Gxlcms > PHP教程 > php连接sqlserver数据库

php连接sqlserver数据库

时间:2021-07-01 10:21:17 帮助过:19人阅读

安装好php的sqlsrv模块
//本地连接
$serverName = "CX95DLISVW4C6TK\aaa";//计算机名\实例名
$connectionInfo = array("Database"=>"fff","ConnectionPooling"=>'','UID'=>'sa','PWD'=>'123');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}else{
echo "dfdf";
$query=sqlsrv_query($conn,"select * from dbo.fdsf");
while($row = sqlsrv_fetch_array($query)){
print_r($row);
}
//print_r($query);
}

//远程连接
$serverName = "192.168.1.5";
$connectionInfo = array("Database"=>"CIA","ConnectionPooling"=>'','UID'=>'sa','PWD'=>'360kad.com');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}else{
echo "dfdf";
$query=sqlsrv_query($conn,"select * from CodeSiteTaker_Model");
while($row = sqlsrv_fetch_array($query)){
print_r($row);
}
//print_r($query);
}

人气教程排行