-1

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));  
}  
  • 2
    https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX7246923.jpg - it's annoying when someone just gives you an image of the code/reason isn't it? Please add the error message to the question *as text* not a linked image. – CD001 Jun 25 '18 at 15:17
  • Read the error message. Login failed, probably because that sql user does not have access to that database. – aynber Jun 25 '18 at 15:19
  • I am getting `Login Failed` Without seeing your connection script anything else would just be supposition – RiggsFolly Jun 25 '18 at 15:26
  • _wampp_ Do you mean WAMPServer or XAMPP or something else? and WHAT is at version 5.3 – RiggsFolly Jun 25 '18 at 15:31
  • Post your my.cnf file (replace any sensitive data in the file) and the actual error text and the actual connection code/string you're using. – Terry Carmen Jun 25 '18 at 15:37
  • I have included the code too. @CD001 I think it's fine know and enough for you to figure out the problem? kindly tell me if you have any query. – Wajahat Ali Jun 25 '18 at 18:32
  • Sorry - but all that shows is that the login failed: *"Login failed for user 'NT AUTHORITY\SYSTEM'"* (from your error message image); since you've not specified `UID` or `PWD` in `$connectionInfo` that means it's using Windows Authentication - try [this link](https://stackoverflow.com/questions/24822076/sql-server-login-error-login-failed-for-user-nt-authority-system), might help. – CD001 Jun 26 '18 at 08:27

1 Answers1

0

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

devangana
  • 46
  • 3