php连接sql server数据库

  • A+
所属分类:php教程
摘要

安装好php的sqlsrv模块 //本地连接 $serverName = “CX95DLISVW4C6TK\aaa”;//计算机名\实例名 $connectionInfo = array(“Database”=>”fff”,”ConnectionPooling”=>”,’UID’=>’sa’,’PWD …

安装好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);

}

weinxin
欢迎加入中国站长博客之家
本站的所有资源都会上传分享到博客之家,希望大家互相学习交流进步。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: