Julian
Julian

Reputation: 3859

Cannot connect to SQL Server in PHP

I trying to connect to a MSSQL Server with PHP. For that I am using the following script:

function mssqli_connect($server,$username,$password,$database){
    $connectionInfo = array("Database"=>$database, "UID"=>$username, "PWD"=>$password);
    return sqlsrv_connect($server,$connectionInfo);
}

I am running PHP 7.0.7 on a Windows Server with the IIS 7.5. Unfortunately it doesn't work and I have no idea why.

What I've already tried

I dumped the function, but it only returns bool(false), which is not very helpful. I also tried to ping the server via cmd. This has succeeded. The credentials are also correct.

The extension php_sqlsrv_7_nts.dll is also requested in the php.ini, so it doesn't give me an error, that the function wasn't found.

Do I miss something, which is required?

Upvotes: 0

Views: 4180

Answers (1)

Julian
Julian

Reputation: 3859

I searched again. Now what I found is an other driver software, which is a msi executable file, which installs the odbc driver on the machine.

https://www.microsoft.com/de-ch/download/details.aspx?id=36434

I installed that software and now it works without any problems.

Thanks for all your comments.

Upvotes: 1

Related Questions