Home > Backend Development > PHP Tutorial > php操作mssql

php操作mssql

WBOY
Release: 2016-06-23 14:34:12
Original
1066 people have browsed it

 $conn=@mssql_connect("127.0.0.1","sa","database") or die("连接错误");

 mssql_select_db("test") or die("没有此数据库");

 $sql="select * from login";

 $result=mssql_query($sql);

 while($row=mssql_fetch_assoc($result))
 {
  echo $row['id']."  ".$row['user']."
";

 }


 mssql_close($conn);
//==========================================================
PHP连接Sql Server  

修改php.ini 
1.将;extension=php_mssql.dll前的;号去掉。 
2.确认extension_dir为正确路径,以本机为例:extension_dir = "C:\php\extensions" 

ok,重启服务器,测试ing... 

如果不行请尝试下面方法: 

PS:在同学几台电脑上都测试通过,但在自已机器上报错说找不到c:\php\extensions\php_mssql.dll但明明存在这个文件。 

解决方法: 
将php_mssql.dll,ntwdblib.dll放到系统目录\system32下重启测试。。。 

(注:上面两个dll文件不在相同目录下,请自已查找。 ^_____^)  

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template