Home  >  Article  >  Backend Development  >  按照步骤做的,php仍然不能连接到SQL Server2005 ?该如何解决

按照步骤做的,php仍然不能连接到SQL Server2005 ?该如何解决

WBOY
WBOYOriginal
2016-06-13 13:34:02868browse

按照步骤做的,php仍然不能连接到SQL Server2005 ??
1.下载正确版本的 ntwdblib.dll (2000.80.194.0)
2.配置php
a、打开php.in将extension=php_mssql.dll的注释符号去掉。
b、打开php.in将mssql.secure_connection = Off改为on。
c、将php_mssql.dll和ntwdblib.dll拷贝到php.in中extension_dir 指定的目录或者系统system32目录下。重启apache。
3.配置了sqlserver,重启

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php if(mssql_connect('127.0.0.1,1433','sa','sa123')){ 
echo   "Link SQL Server 2005 success!! "; 
} 
else   { 
echo   "Fail "; 
} 
?>



结果Fail,还要怎么改啊??

------解决方案--------------------
mssql_connect('127.0.0.1:1433','sa','sa123')
一般可省略默认端口
mssql_connect('127.0.0.1','sa','sa123')
------解决方案--------------------
连接字符串写错了吧,1433前不是逗号,而是分号吧
------解决方案--------------------

echo "Fail ";
改为
echo mssql_get_last_message();
------解决方案--------------------
用pdo比较好
Statement:
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