PHP v5.6 PDO on MS SQL Server 2014
<h2>Issue</h2>

<p>I am currently unable to connect to my database using PDO in PHP.</p>

<hr>

<h2>Specs</h2>

<ul>
<li>PHP version 5.6.9</li>
<li>Database: Microsoft SQL Server 2014 on 2008 R2</li>
<li>From phpinfo(): PDO drivers: mysql, odbc, sqlite</li>
<li>Using IIS 6.1</li>
</ul>

<hr>

<h2>What I've tried</h2>

<p>I have just installed the drivers in the SQLSRV32.exe file from Microsoft (from this link: <a href="https://www.microsoft.com/en-us/download/details.aspx?id=20098" rel="nofollow">https://www.microsoft.com/en-us/download/details.aspx?id=20098</a>) to my PHP extensions folder, however I still cannot seem to connect to my database. (And yes, I restarted IIS)</p>

<p>I can get the connection to work with older connection methods.</p>

<hr>

<h2>My Code</h2>

<p>My current PHP code for PDO connection is as follows:</p>

<pre><code>try {
    $this-&gt;pdo = new PDO('odbc:host='.$this-&gt;hostname.':'.$this-&gt;port.';dbname='.$this-&gt;database,$this-&gt;username,$this-&gt;password);
} catch (PDOException $e) {
    echo 'Failed to get DB handle: '.$e-&gt;getMessage().'&lt;br/&gt;';
    exit;
}
</code></pre>

<p>The above code is inside my MyPDO class constructor so that when I instantiate my class, it is connected <code>$pdo = new MyPDO();</code>.</p>

<hr>

<h2>My Code's Result</h2>

<p>The issue is that I am getting this error as output: </p>

<p><code>Failed to get DB handle: SQLSTATE[IM002] SQLDriverConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified</code></p>

<p>Any help resolving this issue is greatly appreciated!</p>