Data | database | questions
Today configured a new server, configuration is iis+php, the results of the runtime found that PHP connection remote MSSQL database error, error code as follows:
Warning:mssql_connect (): Unable to connect to server:
Think of the past is no problem, how is it? Later went to the internet search, found an article, only to find that the original server is required to install MSSQL to use PHP to connect MSSQL, originally the new server I do not need to use MSSQL, but now there is no way, can only put it on, installed after the MSSQL will be no problem.
I was thinking, if it is on the Linux apache+php will be, it is impossible to install MSSQL Bar, oh, dizzy.
Here is an article to find.
PHP Configuration:
In the php.ini file, set the following to find
Extension=php_mssql.dll remove the semicolon from the front.
Find Extension_dir = d:\extension\
Your php.ini may not be d:\extension\.
Change to the extensions directory below the PHP installation directory Php_mssql.dll, where the path is, if you haven't moved it to another place (assuming your PHP installation path is d:\php)
Change it into extension_dir=d:\php\extensions\.
Then restart the Web server
This is easy to do, but after this setting is still not connected, the wrong message is as follows:
MS SQL Server database connection Error! Please check that the database host variable settings are correct!!!
And the host's variable settings I am over and over again, those settings are not a problem, go through the Web page, found the following clues:
Php.com Information:
I am trying to connect to SQL Server PHP
I bumped to following warning:
Warning:mssql_connect (): Unable to connect to Server:server\portal
... on line 5
On line 5 There is:
$db _connect = mssql_connect (' server\portal ', ' sa ', ' my_passwd ');
I did the following
1.enabled php_mssql.dll Extension in php.ini
2.every DLL is in proper place (System32 or PHP folder), including Ntwdblib.dll
I search Lots of profile throught Web, but no. one give me proper answer to resolve it.
After a few hour, I found the problem is caused by
Ntwdblib.dll, which version is 7.00.839, where I replaced old ntwdblib.dll with the new
Ntwdblib.dll, which version is 8.00.194, all problem are solved.
We had some, read A LOT, of problems with MSSQL under Windows 2003.
We had 2 the same windows, PHP, Php-ini, everything machines only one but connect.
Unable to connect is the error message.
Finnaly we checked the version of Ntwdblib.dll and the one distributed with PHP is 7.00 ....
And the version of the "One on" SQL Server install was 8.00 .... So we copied this one in
The PHP and Apache dir and it worked.
The problem was found, and the trouble was it ntwdblib.dll
The primary role of Ntwdblib.dll is to provide SQL Server connection services.
I used the version of PHP is 4.3.9, in the installation of its windows/system32/I found the Ntwdblib.dll file version is 2000.2.8.0, this version is supported by SQL Server 7.0, Because when you install PHP, you will overwrite all the files below DLLs to the system
directory, so when I use it to connect to SQL Server 2000, of course I will not be able to connect.
Later, I found the version of Ntwdblib.dll on a server with a normal install of SQL Server 2000 is 2000.80.2039.0, I copy this file to the past, overwriting the previous version, restart the server, everything is normal. Add: If the database name starts at the beginning of a number will also be prompted not to open, then to do is very simple, the name of the database in brackets [] around the finished, such as 123bbs rewrite into [123bbs] There is no problem, in addition if your database name and SQL This is also the case with reserved word conflicts in the server, as can be resolved by means of parentheses.
Finally, the problem of PHP incorrectly connecting to SQL Server 2000 is finally solved, although it takes a long time, but the harvest is still very large, now put it out, but also let the brothers encounter the same problem less to take some detours.