PHP interacts with MSSQL data

Source: Internet
Author: User

PHP after the 5.3 version of the interaction with the MSSQL changes, the original MSSQL function system is no longer supported, the use of the SQLSRV function provided by Microsoft, using the SQLSRV function required by Microsoft to provide the Dynamic function library SQL Server Driver for PHP.

Download the library from the official Microsoft website and load the library in the php.ini file to use the library's API

Currently the official library version only supports php5.4 and the following versions, the php5.5 is not supported temporarily, if required php5.5 version can use unofficial compiled version.

The following is an example of how PHP uses the SQLSRV function to interact with MSSQL data:

<?PHP/*$serverName Specifies the name of the server to which you want to connect, including the instance name (for example, "Myserver\instancename") common default values (local), 127.0.0.1, Localhostsqlsrv_connect Opening a database connection requires two parameters (the second parameter is in the form of an array) sqlsrv_errors output error message sqlsrv_close close connection*/$serverName= "(local)";$connectionInfo=Array("Database" = "AdventureWorks", "UID" = "sa", "PWD" = "123456"");$conn= Sqlsrv_connect ($serverName,$connectionInfo);if($conn ){     Echo"Connection established.\n";}Else{     Echo"Connection could not being established.\n";  die(Print_r(Sqlsrv_errors (),true));}/*Close the connection.*/Sqlsrv_close ($conn);?>

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.