PHP link SQLSERVER notes of attached to dll file download

  • 2020-05-19 04:18:27
  • OfStack

Environment:
- Apache 2.2.6
- PHP 5.2.5
- SQL Server 2005
- Windows XP SP2
Steps:
1. First, configure PHP5 to connect MS SQL Server as usual
2. Download the correct version of ntwdblib.dll (2000.80.194.0).
Address: / / www. ofstack. com/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 Configuration Manager and open the protocol Protocols
6. Allow named pipes "named pipes" and "tcp/ip"
7. Right click "tcp/ip" and open the property Properties tag "IP addresses".
8. Fill in 1433 on TCP dynamic port "TCP Dynamic Ports"
9. Restart SQL Server, Apache and PHP
Connect MS SQL Server 2005 by:
mssql_connect('localhost,1433', USERNAME, PASSWORD);

Configuration php

1. Open php.in and remove the annotation symbol extension= php_mssql.dll.
2. Open php.in and change mssql.secure_connection = Off to on.
3. Copy php_mssql.dll to the directory extension_dir specified in php.in or system system32. (php_mssql.dll is available in the php compressed installation package).
You need to restart apache after the above steps are completed.
Note: in practice, if you manually install php under iis via php zip file, you must restart the machine instead of just iis.
4. You need to ensure that php or system system32 has ntwdblib.dll, check the properties to make sure its version is 8.00.194 instead of 7.0...
Other Settings
If php apache Sql Server2000 were on the same machine, access would be fine.
If Sql Server2000 and php machines are separate, confirm that the machine name of ping sqlserver machine is passable. If not, modify the hosts file under system32 drivers\etc on the machine php sqlserver, and add 1 line to the machine name of ip sqlserver sqlserver machine.
If you still cannot access it, you need to make sure that the machine where php is located has no hidden mdac. Or just install the sqlserver client for 1.
In order to connect php to sql2005, I found a lot of information on the Internet in my csdn blog
php connected sql2005 problem, now integrate, at the same time integrate FAQ on.

The tutorial I wrote earlier:

Configuration system before connection:
1. Check the file php5.2.5 \ ntwdblib. dll.
. Download the correct version of ntwdblib dll (2000.80.194.0), address: / / www ofstack. com/dll/ntwdblib dll. html
2. Configuration php
a, open php.in and remove the comment symbol extension= php_mssql.dll.
b, open php.in and change mssql.secure_connection = Off to on.
c, copy php_mssql.dll to the directory extension_dir specified in php.in or system system32. php_mssql.dll is available in the compressed installation package of php.
Restart apache after the above steps are completed.
Note: it has been found in practice that if you manually install php to iis via the php zip file, you must restart the machine and not just iis.
3. The configuration sqlserver
a. Run SQL Server configuration manager: SQL Server Configuration Manager, open the protocol Protocols
b. Allowed to name pipes "named pipes" and "tcp/ip"
c. Right click "tcp/ip" and open the property Properties label "IP addresses".
d. Fill in 1433 at TCP dynamic port "TCP Dynamic Ports"
e. Restart SQL Server


4. Connect MS SQL Server 2005 by:
The code is as follows:
 
// Linked database  
$conn=mssql_connect('localhost','sa','123456'); 
mssql_select_db('gu_dde',$conn); 
//query statements  
$Query="select * from dde_top"; 
$AdminResult=mssql_query($Query); 
// The output  
$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 frequently asked questions:
1 an error:
Fatal error: Call to undefined function mssql_connect()
Solution:
Use the MSSQL_ series of functions
To use both, you need to set it in php.ini:
(1) if DCOM is allowed, php.ini is required; com. allow_dcom= semicolon before TRUE ";" Get rid of.
(2) to use the MSSQL extension, php.ini is required; extension= php_mssql.dll ";" Get rid of. (key)
(3) make sure extension_dir is the correct path. Take the machine as an example: extension_dir = "c:\ AppServ5.2.6 \php\ext".
(4) if the machine still reports that it cannot find c:\ AppServ5.2.6 \php\ext\ php_mssql.dll but the file clearly exists.
. Solution: will php_mssql dll, ntwdblib dll copied to the system directory \ system32 restart under 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)
In addition, remember to restart the server after setting it up.
2.mssql_connect() Unable to connect to server
Confirm that SQLServer2005 server is working. Check that TCP/IP is enabled
Right click to view properties:
Has been enabled to select yes or no
After confirming that the server is correct, confirm again whether the ntwdblib.dll file location is placed under c:\windows\system32
At the same time, make sure that the version of ntwdblib.dll corresponds to the version of sqlserver:
Here is the correspondence:
2.ntwdblib.dll version is 2000.2.8.0, which corresponds to SqlServer2000(this is the Internet information and guess, not 2000)
2.ntwdblib.dll version is 2000.80.194.0, which corresponds to SqlServer2005(this is proved to be applicable by experiments, and I installed 2005 in my laptop)
3.ntwdblib.dll version is 2000.80.2039, which corresponds to SqlServer2008(this is supposed not to install 2008).
6. Other questions:
If the php apache Sql Server2000 were all on the same machine, access would be fine.
If Sql Server2000 and php machines are separate, confirm that the machine name of ping sqlserver machine is passable. If not, modify the hosts file under \system32\drivers\etc machine and add 1 line to the machine name of ip sqlserver machine on which sqlserver is located.
If you still cannot access it, you need to make sure that the machine where php is located has no hidden mdac. Or just install the sqlserver client for 1.
The solution is 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 is easy to appear
ntwdblib2093.dll be careful about the version of this file, otherwise you will get depressed later.
If your MSSQL database is 2000, the operation is basically the same.
Add 1 server of win2003 server system. php 5.0/5.1 was previously used on other servers, and the database was SQL Server 2000; This time, we intend to install SQL Server 2005, php 5.3.2; It is reported that version php 5.3 USES Microsoft's FastCGI mode. Compared with the traditional CGI mode, this mode adopts a more reasonable parsing process startup mode, which is 2 times faster than CGI. The ISAPI mode is no longer supported in PHP5.3 and above.

After having 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;

Related articles: