The article was found on the Internet and has never been obtained. It has always been php + mysql. Now, I don't understand php + mssql. There is no way to find some information from the Internet, after reading these materials, I felt really hard for the first time that mssql was connected. These may not need to be fully read. So am I, maybe I'm stupid! Haha
The article was found on the Internet and has never been obtained. It has always been php + mysql. Now, I don't understand php + mssql. There is no way to find some information from the Internet, after reading these materials, I felt really hard for the first time that mssql was connected. These may not need to be fully read. So am I, maybe I'm stupid! Haha
Environment:
-Apache 2.2.6
-PHP 5.2.5
-SQL Server 2005
-Windows XP SP2
Steps:
1. Configure PHP5 to connect to ms SQL Server as usual
2. Download the correct version of ntwdblib. dll (2000.80.194.0). Note that this version number does not work for this version of dll. It has been a long time since it started to discover this problem. Remember...
Address:
3. Overwrite apache2.2.6 \ bin \ ntwdblib. dll
4. Overwrite php5.2.5 \ ntwdblib. dll
5. run SQL Server Configuration Manager: SQL Server Configuration Manager to enable Protocols.
6. Allow named pipelines "named pipes" and "TCP/IP"
7. Right-click "TCP/IP" to open the Properties tag "ip addresses"
8. Enter 1433 in the TCP Dynamic port "TCP Dynamic Ports ".
9. Restart SQL Server, Apache, and PHP
Connect to ms SQL Server 2005 using the following methods:
Mssql_connect ('localhost, 100', USERNAME, PASSWORD );
Configure php
1. Open php. in and remove the annotation symbol of extension = php_mssql.dll.
2. Open php. in and change mssql. secure_connection = Off TO on.
3. Copy php_mssql.dll to the directory specified by extension_dir in php. in or the system32 directory of the system. (Php_mssql.dll is included in the php compression installation package ).
After completing the preceding steps, restart apache.
Note: in actual use, if php is manually installed under iis through the php compressed file, the machine must be restarted, not just iis.
4. Ensure that ntwdblib. dll is available in php or system32, and check the attribute to make sure that the version is 8.00.194 instead of 7. 0 ......
Other settings
If php apache SQL Server2000 is on the same machine, the access is basically normal.
If the SQL Server and php machines are separated, make sure that the machine name on which the SQL Server server is located can be pinged, modify the hosts file under \ system32 \ drivers \ etc of the machine where php is located, and add the name of the machine where the ip address of the machine where SQL server is located.
If the connection is still inaccessible, check whether the machine on which php is located is converted to mdac. Or simply install the SQL Server Client.
For php connection to sql2005, I found a lot of information on the network in my csdn blog. at, I finally got it done.
Php connection to sql2005 is now integrated, and FAQ is integrated.
The tutorial I wrote earlier:
Configure the system before connection:
1. Check the php5.2.5 \ ntwdblib. dll file. One of the following is under the default file and cannot be connected and replaced.
Download the correct version of ntwdblib. dll (2000.80.194.0):
2. Configure php
A. Open php. in and remove the annotation symbol of extension = php_mssql.dll.
B. Open php. in and change mssql. secure_connection = Off TO on.
C. Copy php_mssql.dll to the directory specified by extension_dir in php. in or the system32 directory of the system. (Php_mssql.dll is included in the php compressed installation package ).
After completing the preceding steps, restart apache.
Note: in actual use, if php is manually installed under iis through the php compressed file, the machine must be restarted, not just iis.
3. Configure sqlserver
A. run SQL Server Configuration Manager: SQL Server Configuration Manager to enable Protocols.
B. Allow named pipelines "named pipes" and "TCP/IP"
C. Right-click "TCP/IP" and open the Properties tag "ip addresses"
D. Enter 1433 in the TCP Dynamic port "TCP Dynamic Ports ".
E. Restart SQL Server
4. Use the following method to connect to ms SQL Server 2005:
The Code is as follows:
The Code is as follows:
// Link to the database
$ Conn = mssql_connect ('localhost', 'sa ', '123 ');
Mssql_select_db ('Gu _ dde ', $ conn );
// Query statement
$ Query = "select * from dde_top ";
$ AdminResult = mssql_query ($ Query );
// Output result
$ Num = mssql_num_rows ($ AdminResult );
For ($ I = 0; $ I <$ Num; $ I ++)
{
$ Row = mssql_fetch_array ($ AdminResult );
Echo ($ Row [1]);
Echo ("");
}
?>
Enter http: // 127.0.0.1/
5. FAQ FAQs:
1 error:
Fatal error: Call to undefined function mssql_connect ()
Solution:
Use MSSQL _ series Functions
To use these two methods, you need to set them in php. ini:
(1) To allow DCOM, remove the Semicolon ";" before com. allow_dcom = TRUE in php. ini.
(2) to use the MSSQL extension, remove the Semicolon ";" in php. ini before extension = php_mssql.dll. (Key)
(3) confirm that extension_dir is the correct path. Take the local machine as an example: extension_dir = "c: \ AppServ5.2.6 \ php \ ext ".
(4) If the server still reports an error, the file c: \ AppServ5.2.6 \ php \ ext \ php_mssql.dll cannot be found, but the file exists clearly.
Solution: Copy php_mssql.dll and ntwdblib. dll to the system directory \ system32 and restart the test ..
(Note: The above two dll files are not in the same directory. My files are c: \ AppServ5.2.6 \ php \ ext \ php_mssql.dll; c: \ AppServ5.2.6 \ php \ ntwdblib. dll)
In addition, remember to restart the server after setting it.
2. mssql_connect () Unable to connect to server
Check whether the SQLServer2005 server is normal. Check whether TCP/IP is enabled.
Right-click to view properties at the same time:
Enabled? Select Yes
After confirming that the server is correct, check whether the ntwdblib. dll file is stored in c: \ windows \ system32.
At the same time, ensure that the version of the ntwdblib. dll file corresponds to that of sqlserver:
The following is the correspondence:
2. If the ntwdblib. dll version is 2000.2.8.0, it corresponds to SqlServer2000 (this is the network query information and speculation, and 2000 is not installed)
2. The ntwdblib. dll version 2000.80.194.0 corresponds to SqlServer2005 (this is an experiment that can be used. I installed 2005 in my notebook)
3. The ntwdblib. dll version 2000.80.2039 corresponds to SqlServer2008 (this is a guess that 2008 is not installed)
6. Other problems:
If php apache SQL Server2000 is on the same machine, the access is basically normal.
If the SQL Server and php machines are separated, make sure that the machine name on which the SQL Server server is located can be pinged, modify the hosts file under \ system32 \ drivers \ etc of the machine where php is located, and add the name of the machine where the ip address of the machine where SQL server is located.
If the connection is still inaccessible, check whether the machine on which php is located is converted to mdac. Or simply install the SQL Server Client.
The solution is as follows:
1. Download two files: php_mssql.dll and ntwdblib. dll.
Php_mssql.dll is easy to appear if it is not copied to c: \ windows \ system32.
Pay attention to the version of the ntwdblib2093.dll file, otherwise it will be very depressing.
If your MSSQL database is 2000, the operations are basically the same.
Add a server in the win2003 server system. In the past, other servers used php5.0/5.1, and the database was SQL Server 2000. This time, we plan to install SQL Server 2005 and php5.3.2. It is understood that php5.3 uses Microsoft's FastCGI mode, compared with the traditional CGI Mode, this mode adopts a more reasonable startup mode for parsing processes, which is twice faster than CGI. The ISAPI mode is not supported in PHP5.3 or later versions.
After iis6 and ms SQL server 2005 have been installed, the entire installation process is
1. Install FastCGI;
2. Install php5.3.2;
3. Install the SQL Server Driver for PHP 1.1 Driver;