[英]Why can't I connect to a Sql Server with PHP?
I wrote code as below: 我写的代码如下:
<?php
$conn = mssql_connect("xx.xx.xx.xx", "username", "password")
or die("Can't connect to server ".mssql_error());
echo "Success";
mssql_close($conn);
?>
The error is: 错误是:
PHP Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: xx.xx.xx.xx in xxxxxxx\\conn.php on line 2 PHP Fatal error: Call to undefined function mssql_error() in xxxxxxx\\conn.php on line 3
PHP警告:mssql_connect()[function.mssql-connect]:无法连接到服务器:第2行的xxxxxxx \\ conn.php中的xx.xx.xx.xx PHP致命错误:调用xxxxxxx \\中未定义的函数mssql_error()第3行的conn.php
The server is Apache2.2, the version of Sql Server is 2005, the version of PHP is 5.2.5, and I remove the ;
服务器是Apache2.2,Sql Server的版本是2005,PHP的版本是5.2.5,我删除了
;
before extension=php_mssql.dll
and there is a php_mssql.dll
in the ext
directory 在
extension=php_mssql.dll
之前,并且ext
目录中有一个php_mssql.dll
Use mssql_get_last_message() 使用mssql_get_last_message()
<?php
$conn = mssql_connect("xx.xx.xx.xx", "username", "password")
or die("Can't connect to server ".mssql_get_last_message());
echo "Success";
mssql_close($conn);
?>
服务启动时,是否可以检查apache日志中mssql扩展是否有问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.