user1487718
user1487718

Reputation:

SQL Server 2012 Connection Error from PHP

I am using this code to log in to sql server express 2012

   <?php 
      $serverName = "SD-20120627VVKE\SQLEXPRESS";

    $connectionOptions = array("Database"=>"android_api");

    $conn = sqlsrv_connect( $serverName, $connectionOptions);

    if( $conn === false )

          { die( FormatErrors( sqlsrv_errors() ) ); }
    ?> 

but I get this screen

enter image description here

How should I solve it?

Upvotes: 2

Views: 2208

Answers (1)

william007
william007

Reputation: 18525

Try this:

<?php
$server = "SD-20120627VVKE\\SQLEXPRESS";
$options = array(  "UID" => "<username>",  "PWD" => "<password>",  "Database" => "android_api");
$conn = sqlsrv_connect($server, $options);
if ($conn === false) die("<pre>".print_r(sqlsrv_errors(), true));
echo "Successfully connected!";
sqlsrv_close($conn);
?>

Upvotes: 1

Related Questions