I'm trying to get a connection to MS SQL up and running via PHP on my machine. I'm running IIS, have PHP 7.2 installed and MS SQL Express 2017. I have my basic web page running but when I click to open the PHP page, the connection does not work.
session_start();
echo "Hello ";
if (isset($_POST['submit'])) {
$_SESSION["server"] = $_POST['server'];
$_SESSION["database"]= $_POST['database'];
$_SESSION["username"] = $_POST['username'];
$_SESSION["password"] = $_POST['password'];
echo $_SESSION["database"];
//CONNECTION
$serverName = $_SESSION["server"];
$connectionInfo["Database"] = $_SESSION["database"];
$connectionInfo["UID"] = $_SESSION["username"];
$connectionInfo["PWD"] = $_SESSION["password"];
echo "midway";
$conn = sqlsrv_connect($serverName, $connectionInfo);
echo "Bye";
}
When I run this I get "Hello dimensions midway" which suggests the page is working until it hits the connection line.
I am not sure what sqlsrv extension to use.
I have looked around and can see versions for 7 and 7.1 but not for 7.2.
I have added in extension=php_sqlsrv_71_nts_x86.dll
to the bottom of php.ini (and the file exists in C:\Program Files (x86)\PHP\v7.2\ext
).
Any pointers would be gratefully received. I've spent a couple of days on this and don't think I'm getting anywhere.
Thanks