PHP Connection SQL Server considerations (DLL file download) _php tutorial

Source: Internet
Author: User
Tags sql server driver
Environment:
-Apache 2.2.6
-PHP 5.2.5
-SQL Server 2005
-Windows XP SP2
steps:
1. First configure the PHP5 connection MS SQL Server as usual
2. Download the correct version of Ntwdblib.dll (2000.80.194.0), note that this version number, not this version of the DLL does not work Ah, just started to have a long time to find this problem, remember ...
Address: http://www.jb51.net/dll/ntwdblib.dll.html
3. Cover Apache2.2.6\bin\ntwdblib.dll
4. Cover Php5.2.5\ntwdblib.dll
5. Run SQL Server Configuration Manager: SQL Server Config Manager, open protocol protocols
6. Allow Named pipes "Named Pipes" and "TCP/IP"
7. Right-click on "TCP/IP" to open the Property Properties tab "addresses"
8. Fill in the TCP dynamic port "TCP Ports" in 1433
9. Restart SQL Server, Apache, and PHP
Connect MS SQL Server 2005 using the following methods:
Mssql_connect (' localhost,1433 ', USERNAME, PASSWORD);

Configure PHP

1. Open php.in to remove the extension=php_mssql.dll annotation symbol.
2. Open php.in to change mssql.secure_connection = off to ON.
3, copy the Php_mssql.dll to the php.in extension_dir the specified directory or the system system32 directory. (Php_mssql.dll is available in the PHP compression installation package).
You will need to restart Apache after the above steps have been completed.
Note: In practice, it is found that the machine must be restarted, not just IIS, if it is manually installed through PHP compressed files to IIS.
4, need to ensure that PHP or system system system32 under the Ntwdblib.dll, check the properties to ensure that its version is 8.00.194 instead of 7.0 ...
Other Settings
If PHP Apache SQL Server2000 are on the same machine, access is basically no problem.
If SQL Server2000 and PHP machines are separate, you need to verify that the machine name of the machine where the ping SQL Server is located can pass, if it does not pass, modify the Hosts file under the \System32\Drivers\Etc of the machine where PHP is located, add a line Machine name of machine IP SQL Server where SQL Server is located.
If you are still unable to access it, you need to verify that the machine on which PHP is located has installation MDAC. or simply install SQL Server client as well.
In order to connect PHP sql2005, I found a lot of information on the network in my CSDN blog. It's 3:05 in the evening.
PHP connection sql2005 problem, now integration, while the FAQ integration.

The Tutorial I wrote earlier:

Configure the system before connecting:
1. Check the file Php5.2.5\ntwdblib.dll by default there is one, cannot connect and replace.
Download the correct version of Ntwdblib.dll (2000.80.194.0), Address: http://www.jb51.net/dll/ntwdblib.dll.html
2. Configure PHP
A. Open php.in to remove the extension=php_mssql.dll annotation symbol.
B. Open php.in to change mssql.secure_connection = off to ON.
C, copy the Php_mssql.dll to the php.in extension_dir the specified directory or the system system32 directory. (Php_mssql.dll is available in the ZIP installation package for PHP).
You will need to restart Apache after the above steps have been completed.
Note: In practice, it is found that the machine must be restarted, not just IIS, if it is manually installed through PHP compressed files to IIS.
3. Configure SQL Server
A. Running SQL Server Configuration Manager: SQL Server Config Manager, opening protocol protocols
B. Allow Named pipes "Named Pipes" and "TCP/IP"
C. Right-click on "TCP/IP" to open the Properties property tag "addresses"
D. Filling in TCP dynamic port "TCP Ports" 1433
E. Restarting SQL Server


4. Connect MS SQL Server 2005 using the following method:
The code is as follows:
Copy CodeThe code is as follows:
Link Database
$conn =mssql_connect (' localhost ', ' sa ', ' 123456 ');
mssql_select_db (' Gu_dde ', $conn);
Query statement
$Query = "SELECT * from Dde_top";
$AdminResult =mssql_query ($Query);
Output results
$Num =mssql_num_rows ($AdminResult);
for ($i =0; $i < $Num; $i + +)
{
$Row =mssql_fetch_array ($AdminResult);
Echo ($Row [1]);
Echo ("");
}
?>

Input HTTP://127.0.0.1/


5.FAQ FAQ:
1 Error:
Fatal error:call to undefined function mssql_connect ()
Solve:
Using the MSSQL_ series functions
To use both of these, you need to set the php.ini:
(1) Allow DCOM, need to be in php.ini; Com.allow_dcom=true before the semicolon ";" Remove.
(2) The use of MSSQL extension, need php.ini; Extension=php_mssql.dll before the semicolon ";" Remove. Key
(3) Confirm that Extension_dir is the correct path, take this machine as an example: Extension_dir = "C:\AppServ5.2.6\php\ext".
(4) If the machine error is still not found C:\AppServ5.2.6\php\ext\php_mssql.dll but clearly exists this file.
Workaround: Copy the Php_mssql.dll,ntwdblib.dll to the system directory \system32 to restart the test.
(Note: The above two DLL files are not in the same directory, mine is C:\appserv5.2.6\php\ext\php_mssql.dll;c:\appserv5.2.6\php\ntwdblib.dll)
Also, remember to restart the server after you set it up well.
2.mssql_connect () Unable to connect to server
Verify that the SQLServer2005 server is healthy. Check that TCP/IP is enabled
Right-click to view the properties at the same time:
has enabled whether to select Yes
After confirming that the server is correct, confirm that the Ntwdblib.dll file location is placed under C:\Windows\System32
Also make sure that the version of Ntwdblib.dll this file corresponds to the version of SQL Server:
The following are the corresponding relationships:
2.ntwdblib.dll version for 2000.2.8.0 is the corresponding SqlServer2000 (this is the Web check data and guessing, not loaded 2000)
2.ntwdblib.dll version for 2000.80.194.0 is the corresponding SqlServer2005 (this is the experimental proof can be used, I was a notebook loaded 2005)
3.ntwdblib.dll version for 2000.80.2039 is correspondence SqlServer2008 (this is guessing not loaded 2008)
6. Other issues:
If PHP Apache SQL Server2000 are on the same machine, access is basically no problem.
If SQL Server2000 and PHP machines are separate, you need to verify that the machine name of the machine where the ping SQL Server is located can pass, if it does not pass, modify the Hosts file under the \System32\Drivers\Etc of the machine where PHP is located, add a line Machine name of machine IP SQL Server where SQL Server is located.
If you are still unable to access it, you need to verify that the machine on which PHP is located has installation MDAC. or simply install SQL Server client as well.
Solve the problem as follows:
1. Download two files Php_mssql.dll and Ntwdblib.dll
Php_mssql.dll If this is not copied to C:\Windows\System32, it will be easy to appear
Ntwdblib2093.dll this file to pay attention to the version, or behind the very depressed.
If your MSSQL database is 2000, the operation is basically the same.
Add a server for the Win2003 server system. Previously, the database was SQL Server 2000 using php5.0/5.1 on other servers, and this time you are going to install SQL Server 2005. php5.3.2; It is understood that the php5.3 version uses Microsoft's FASTCGI model, this mode and the traditional CGI mode compared to a more reasonable parsing process startup mode, faster than CGI twice times faster than the version of PHP5.3, the ISAPI mode is not supported.

After you have installed IIS6 and MS SQL Server 2005, the entire installation process is
1. Install fastcgi;
2. Install php5.3.2;
3. Install SQL Server Driver for PHP 1.1 driver;

http://www.bkjia.com/PHPjc/325522.html www.bkjia.com true http://www.bkjia.com/PHPjc/325522.html techarticle Environment:-Apache 2.2.6-php 5.2.5-sql Server 2005-windows XP SP2 steps: 1. Configure the PHP5 connection first as usual to connect MS SQL Server 2. Download the correct version of the NTWD Blib.dll ( ...

  • Related Article

    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.