PHP和SQL Server 2005开发环境

首先请到此处下载驱动

http://www.microsoft.com/downloads/details.aspx?FamilyId=61BF87E0-D031-466B-B09A-6597C21A2E2A&displaylang=en

 

配置:

1.将php_sqlsrv.dll 或 php_sqlsrv_ts.dll 放到PHP的扩展目录中(PHP/EXT)。
2.编辑php.ini文件,添加以下扩展:
extension=php_sqlsrv.dll

extension=php_sqlsrv_ts.dll
3.重启服务器。

 

示例:

$dbbase='mydb'; //your db name
$uid='sa';    //your username
$pwd='sa';  //your password


$connectionInfo=array("Database"=>$dbbase,"UID"=>$uid,"PWD"=>$pwd);


$serverName="SQLEXPRESS"; //your serverName


$conn=sqlsrv_connect($serverName,$connectionInfo) or die("Connection could not be established. ");


$strSql = " select * from A ";
         
$stmt = sqlsrv_query($conn,$strSql);

 

while(sqlsrv_fetch($stmt)){
    echo sqlsrv_get_field($stmt,0);

    echo "<br>";
}


sqlsrv_close($conn);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值