打开PHP配置文件php.ini,找到;extension=php_mssql.dll把前面的分号去掉,2、找到mssql.secure_connection = Off修改成 mssql.secure_connection = On,3、把PHP文件夹下的php_mssql.dll和ntwdblib.DLL这两个文件拷贝到C:windowssystem32文件夹下
在这里,复制ntwdblib.dll到c:windowssystem32下是失败,原因是该目录下已经存在该dll文件啦.重启apache.
$hostname="10.4.250.20"; $dbuser="hr"; $dbpasswd="946138"; $dbname="hr"; $conn = mssql_connect($hostname,$dbuser,$dbpasswd) or die("数据库连接错误!"); mssql_select_db($dbname,$conn); $sql = " select * from pip_staff_s where cstaffid ='z797' "; $rowset=mssql_query($sql,$conn); $rowcnt=mssql_num_row($rowset); echo " rows "; echo $rowset; echo " end ";