sqlsrv函数问题
环境:Apache 2.2.22、PHP 5.3.5、数据库MSSQL2008
mssql这是PHP5.3以前版本的,怎么将以下代码改成PHP5.3之后版本的,即sqlsrv函数,自己曾试着改过一部分,但老是报错,所有只能在此求助各位了!!
<br> session_start();<br> //连接数据库服务器<br> $Link=mssql_connect(".","sa","");<br> //选择数据库<br> mssql_select_db("frienddb");<br> //定义SQL语句<br> <br> $name=$_REQUEST["txtName"]; <br> $address=$_REQUEST["txtAddress"];<br> $group=$_REQUEST["txtGroup"];<br> <br> $sqlstr="";<br> if($name!="")<br> {<br> $sqlstr="mName='".$name."'";<br> }<br> <br> if($sqlstr!="")<br> {<br> if($address!="")<br> {<br> $sqlstr=$sqlstr." and mAddress='".$address."'";<br> }<br> }<br> else<br> {<br> if($address!="")<br> {<br> $sqlstr="mAddress='".$address."'";<br> }<br> }<br> <br> if($sqlstr!="")<br> {<br> if($group!="")<br> {<br> $sqlstr=$sqlstr." and tname='".$group."'";<br> }<br> }<br> else<br> {<br> if($group!="")<br> {<br> $sqlstr="tname='".$group."'";<br> }<br> }<br> <br> <br> if($_REQUEST["Submit"]!="")<br> {<br> $_SESSION["sqltxt"]=$sqlstr;<br> }<br> else<br> {<br> $sqlstr=$_SESSION["sqltxt"];<br> }<br> echo $_SESSION["sqltxt"];<br> <br> if($sqlstr!="")<br> {<br> $Query="select count(*) from myfriends,team where myfriends.tid=team.tid and ".$sqlstr;<br> }<br> else<br> {<br> $Query="select count(*) from myfriends,team where myfriends.tid=team.tid ";<br> }<br> <br> $rs=mssql_query($Query);//查询记录总数<br> $cntrow=mssql_fetch_row($rs);<br> $cnt=$cntrow[0];//记录总数<br> $PageSize=10;//每页显示10条数据<br> //计算总页数<br> if($cnt%$PageSize==0)<br> {<br> $PageCnt=$cnt/$PageSize;<br> }<br> else<br> {<br> $PageCnt=floor($cnt/$PageSize)+1;//总页数<br> }<br> $CurrentPage=floor($_REQUEST["pid"]);//当前页,如果为小数则当前页取值为小于此小数的整数<br> //当前页小于1<br> if($CurrentPage {<br> $CurrentPage=1;<br> }<br> //当前页大于总页数<br> if($CurrentPage>$PageCnt)<br> {<br> $CurrentPage=$PageCnt;<br> }<br> <br> //设置起始页码<br> $Start=$CurrentPage-3;<br> //设置终止页码 <br> $End=$CurrentPage+3; <br> <br> //上一页<br> $PrvPage=$CurrentPage-1;<br> //下一页<br> $NextPage=$CurrentPage+1; <br> if($Start {<br> $Start=1;<br> $End=$Start+6;<br> }<br> <br> if($End>$PageCnt)<br> {<br> $Start=$PageCnt-6;<br> $End=$PageCnt;<br> }<br> <br> if($sqlstr!="")<br> {<br> $sqlstr="select top ".$PageSize." mName,mSex,mBirthday,mTel,mAddress,tname from myfriends,team where myfriends.tid=team.tid and mid not in (select top ".($CurrentPage-1)*$PageSize." mid from myfriends) and ".$sqlstr;<br> <br> }<br> else<br> {<br> $sqlstr="select top ".$PageSize." mName,mSex,mBirthday,mTel,mAddress,tname from myfriends,team where myfriends.tid=team.tid and mid not in (select top ".($CurrentPage-1)*$PageSize." mid from myfriends) ";<br> <br> }<br> //echo $sqlstr;<br> <br> $result=mssql_query($sqlstr);//返回结果集<br> /*<br> mssql_fetch_row//取行数据<br> mssql_fetch_field//取列数据<br> */ <br> <br> ?><br> <br> <title></title><br> <br> <link><br> <br>