PHP

PHP Unable to Connect to MS SQL Server Express Edition

就是说PHP里面的ntwdblib.dll版本太旧,要下载新的版本覆盖就可以了

I’ve been struggling for several hours to find out why PHP 5.2.5 didn’t want to connect to MS SQL Server 2005 Express Edition although extension=php_mssql.dll already enabled and phpinfo() is showing MS SQL already active.

I always got this error messages when trying to connect to MS SQL:

[quote]Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: (local)\SQLEXPRESS in path\mssql.php on line 5[/quote]

After doing some searching, I got an answer that PHP 5 is using old ntwdblib.dll version. The one that comes with PHP 5.2.5 distribution is version 2000.2.8.0 which seems doesn’t compatible with the new MS SQL Server 2005 Express Edition. I downloaded new dll from [url]http://webzila.com[/url] (use the search tool) which is version 2000.80.194.0 and replaced the one on PHP folder with this version.

I use this code to test the connection and its working:echo(“Testing MS SQL connection… “);

if ($conn = mssql_connect(‘(local)\SQLEXPRESS’, ‘user’, ‘pass’))
{
echo(“Connection succeed”);

mssql_select_db(‘dbname’, $conn);
mssql_close($conn);
}
else
{
echo(“Connection failed”);
}

分类: PHP

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部