sqlserver
Also known as MSSQL, it is a relational database management system (DBMS) developed and promoted by Microsoft. The operating software can use "sqlserver"
How does php connect to sqlserver?
First of all, it is clear that wampserver does not support connecting to sqlserver, so you have to download the driver to connect to sqlserver yourself. There are also PHP versions that are 5.3 or above, excluding 5.3
1) Download the Microsoft SQL Server PHP driver. (Recommended learning: PHP Programming from Beginner to Master)
With the Microsoft SQL Server PHP driver, PHP developers can access SQL Server databases. This type of driver relies on the Microsoft SQL Server ODBC driver to handle low-level communication with SQL Server. What I downloaded is 3.0, run the installation and extract it to the PHP extension directory ext,
2) Here I am using the PHP 5.4.45 version, so the driver to be used is
;sqlserver
extension=php_pdo_sqlsrv_54_ts.dll
extension=php_sqlsrv_54_ts.dll
3) The first connection may report an odbc driver error. I checked for a long time and it turns out that it still needs to be installed. sqlserver odbc driver source
Download and install directly
https://www.microsoft.com/en-us/download/confirmation.aspx?id=36434
4) Connection test code
public function index() { //echo phpinfo(); $serverName = "222.180.xxx.xx"; //数据库服务器地址 $uid = "bbapp"; //数据库用户名 $pwd = "bbapp2017"; //数据库密码 $connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"rivermanage"); $conn = sqlsrv_connect($serverName, $connectionInfo); if( $conn == false){ echo "连接失败!"; var_dump(sqlsrv_errors()); exit; }else{ echo "链接成功"; }}
The above is the detailed content of How to connect to sqlserver with PHP. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools
