How to connect to MSSQL in PHP using sqlsrv api?
<p>I am trying to connect to MSSQL in PHP using sqlsrv api. When I run <strong>phpinfo()</strong>, it shows an a section for <strong>sqlsrv</strong>. But while actually writing code, I cannot connect to MSSQL. I am using SQL Server R2. I connect to the database from the Management Studio using the specified hostname. Here is the code:</p>

<pre><code>&lt;?php
        $serverName = "TEST-PC\SQLEXPRESS";
        $databaseName = "TestDB";

        $connectionInfo = array("Database"=&gt;"$databaseName");
        $conn = sqlsrv_connect( $serverName, $connectionInfo);
        if( $conn === false ){
            echo "Could not connect.\n";
            die( print_r( sqlsrv_errors(), true));
        }
        else{
            echo "Connection created";
        }
        $tsql = "SELECT * FROM Test";
        $result = sqlsrv_query($conn, $tsql);
        echo "Rows returned: ".sqlsrv_num_rows($result);
        sqlsrv_close();
    ?&gt;
</code></pre>

<p>The code prints NOTHING on the page, not even any error message. Here is the entries in php.ini file:</p>

<pre><code>extension=php_sqlsrv_53_ts_vc9.dll
extension=php_pdo_sqlsrv_53_ts_vc9.dll
</code></pre>

<p>Any help please?</p>
