Environment PHP5.2.6
SQL2005 Standard Edition
SERVER2003 SP2
1: The SQL2005 file is damaged and cannot be used normally. If the file is not completely uninstalled, the system is reinstalled, which is convenient and convenient.
2: There are some minor issues with the support of MSSQL in PHP configuration. mssql_connect connection mode cannot be connected. Only ODBC connection is allowed.
Solution: Add NTWDBLIB. DLL to SYSTEM32. PHP comes with 7.0, which is invalid for 2005.
It is said that this DLL can be found in the SQL Installation File --!
Two connection methods are provided:
// Mssql_connect connection method
<? Php
// Server and login Info
$ SERVER = 'IP ';
$ USER_NAME = "USER ";
$ USER_PASS = "PASS ";
$ DATABASE = "DBNAME ";
// Connecting to the server
$ CONN = mssql_connect ($ SERVER, $ USER_NAME, $ USER_PASS) or die ("Can't connect to Microsoft SQL Server ");
// Selecting the database
$ Connection = mssql_select_db ($ DATABASE, $ CONN) or die ("Can't connect to Database ");
If ($ connection) printf ("Connected successfully ");
?>
// ODBC connection mode
<? Php
$ Connection_string = 'driver = {SQL Server}; SERVER = IP; DATABASE = dbname ';
$ User = 'user ';
$ Pass = 'pass ';
$ Connection = odbc_connect ($ connection_string, $ user, $ pass) OR die ("?? ");
If ($ connection) printf ("Connected successfully ");
?>
Author "growth footprint"