What permissions and access rights are necessary to successfully connect PHP to MSSQL Server?

To successfully connect PHP to MSSQL Server, you will need to ensure that the necessary permissions and access rights are granted to the user connecting to the database. This typically includes having the appropriate database user credentials, ensuring that the user has permission to access the database, and configuring the MSSQL Server to allow remote connections if needed.

<?php
$serverName = "your_server_name";
$connectionOptions = array(
    "Database" => "your_database_name",
    "Uid" => "your_username",
    "PWD" => "your_password"
);
// Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);

if ($conn) {
    echo "Connection established.";
} else {
    echo "Connection could not be established.";
    die(print_r(sqlsrv_errors(), true));
}
?>