search
HomeBackend DevelopmentPHP7How to connect to sql server in PHP7?


How to connect to sql server in PHP7?

The latest version on the official website is 7.1.3, but this version is inconsistent with the Microsoft PHP SQL driver, resulting in the inability to load the php_sqlsrv_7_ts_x64.dll file. At first I thought it was the 32 and 64 versions that were wrong, but it still didn’t work after changing. Then I tried lowering the version and it worked, as shown below:



Connection code:

<?php $Server="192.168.1.20";
$database="Test";
$uid="sa";
$pwd="123456";
$conInfo=array(&#39;Database&#39;=>$database,'UID'=>$uid,'PWD'=>$pwd);  
$link=sqlsrv_connect($Server,$conInfo);   
  
if( $link ){  
   
}  
else{  
    print_r( sqlsrv_errors(), true);  
   if( ($errors = sqlsrv_errors() ) != null) {  
        foreach( $errors as $error ) {  
            echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br>";  
            echo "code: ".$error[ 'code']."<br>";  
            echo "message: ".$error[ 'message']."<br>";  
        }  
    }  
    die("");  
} 	
?>

Related learning recommendations: PHP Programming from beginner to master

The above is the detailed content of How to connect to sql server in PHP7?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft