PHP connection to MSSQL and errors during use

Source: Internet
Author: User
Tags connect to microsoft sql server odbc connection

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"

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.