What are some common pitfalls to avoid when working with Microsoft SQL server in PHP?

One common pitfall to avoid when working with Microsoft SQL Server in PHP is using deprecated functions like mssql_connect. Instead, it is recommended to use the SQLSRV extension provided by Microsoft for better compatibility and performance. Additionally, always remember to sanitize user input to prevent SQL injection attacks.

// Connect to Microsoft SQL Server using SQLSRV extension
$serverName = "localhost";
$connectionOptions = array(
    "Database" => "dbName",
    "Uid" => "username",
    "PWD" => "password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);

// Sanitize user input to prevent SQL injection
$unsafeInput = $_POST['input'];
$safeInput = sqlsrv_real_escape_string($conn, $unsafeInput);