Questions about PHP not connecting to MSSQL database _php tutorial

Source: Internet
Author: User
Tags apache php
Today, the new server configuration is IIS PHP, the results run the discovery PHP connection remote MSSQL database error, error code is as follows:
Warning:mssql_connect (): Unable to connect to server:

Think about the past is no problem, what is the matter? Later to search online, found an article, only found that the original server is required to install MSSQL to use the PHP connection MSSQL, the new server I do not need to use the MSSQL, but now there is no way, can only put it on, installed MSSQL after the no problem.

I was thinking, if it is on Linux above the Apache PHP will do, it is impossible to install MSSQL, OH, dizzy.

Here is an article that I found.

PHP Configuration:
Set the following in the php.ini file 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 under the PHP installation directory under the Php_mssql.dll, where the path, if you did not move it to another place (assuming that your PHP installation path is d:php)
Change it into a extension_dir=d:phpextensions.
Then restart the Web server


This is easy to do, but after such a setup is still not connected, the error message is as follows:

MS SQL Server database connection Error! Check that the database host variables are set correctly!!!

And the host's variable settings I was the check again and again, those settings are not a problem, to go through the Web page, found the following clues:


Php.com Information:

I am trying to connect to SQL Server in PHP
I bumped to following warning:
Warning:mssql_connect (): Unable to connect to Server:serverportal
.... On line 5

On line 5 There is:
$db _connect = mssql_connect (' serverportal ', ' 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 were caused by
Ntwdblib.dll, which version is 7.00.839, when I replaced old Ntwdblib.dll with the new

Ntwdblib.dll, which version is 8.00.194, all problem is solved.

We had some, read A lot, the problems with MSSQL under Windows 2003.
We had 2 the same windows, PHP, Php-ini, everything machines but only one could 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 ....

The version of the one on the SQL Server install is 8.00 .... So we copied the 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 connectivity services.

I use the PHP version is 4.3.9, in the installation of its service windows/system32/I found that the Ntwdblib.dll file version is 2000.2.8.0, this version is supported by SQL Server 7.0, Because PHP will be installed when all the files below the DLLs are overwritten to the system

directory, so when I use it to connect to SQL Server 2000, of course it will not be able to connect.

Later, I found the version of Ntwdblib.dll on a server that is normally installed on SQL Server 2000 is 2000.80.2039.0, I copy this file over, overwrite the previous version, after restarting the server, everything is OK.

Add: If the database name starts with a number, it will not open, it is very simple to do, put the database name in brackets []
In the case of a 123bbs rewrite [123bbs] There is no problem, in addition, if your database name conflicts with the reserved word in SQL Server, this will also occur, in the same way as the square brackets can be resolved.
Finally, the problem of PHP is not properly connected to SQL Server 2000 finally solved, although the cost of a large half a day, but the harvest is very large, now put it out, but also to meet the same problems of the brothers to take a few detours.

http://www.bkjia.com/PHPjc/630934.html www.bkjia.com true http://www.bkjia.com/PHPjc/630934.html techarticle today, the new server configuration is IIS PHP, the results of the runtime found that the PHP connection remote MSSQL database error, error code is as follows: Warning:mssql_connect (): Unable to connect to Ser ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.