PHP - error connecting to sql server

104 views Asked by At

I have included the driver in extension folder and added that extension in php.ini file too, wampp has version of 5.3. While connecting to sql server via php I am getting error which is below. enter image description here

<?php

/** * CONNECTION TO SQL SERVER * CONNECTING VIA WINDOWS AUTHENTICATION */

/* Specify the server and connection string attributes. */  
$serverName = "Wajahat\SQLEXPRESS";  
$connectionInfo = array( 'Database'=>'modern_ecommerce');  

/* Connect using Windows Authentication. */  
$conn = sqlsrv_connect( $serverName, $connectionInfo);  
if( $conn === false )  
{  
 echo "Unable to connect.</br>";  
 die( print_r( sqlsrv_errors(), true));  
}  
1

There are 1 answers

0
devangana On

Try adding Integrated Security =true in connectring or add username and password. From the error it seems connection cannot be established