Im trying to get a webpage to connect to a database on sql server, but the connection keeps failing. I was wondering if my problem is that I need to use a port to help the webpage connect.
<?php
include 'ConnectionInfo.php';
try
{
$dsn="sqlsrv:Server=$Servername;Database=$Database";
$pdo = new PDO($dsn,$Username,$Password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e)
{
echo "Connection to database failed: " . $e->getMessage();
}
?>