简体   繁体   中英

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

在此处输入图片说明

How should I solve it?

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);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM