Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
<?php
//
ini_set('display_errors','On');
error_reporting(E_ALL | E_STRICT);

$serverName = "WIN-TKQHRGCY678\SQLEXPRESS"; //serverName\instanceName


$connectionInfo = array( "Database"=>"dbTest", "UID"=>"WIN-TKQHRGCY678\MyAccount", "PWD"=>"123456z");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}

?>


i got this message
Connection could not be established.
C#
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'WIN-TKQHRGCY678\MyAccount'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'WIN-TKQHRGCY678\MyAccount'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'WIN-TKQHRGCY678\MyAccount'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'WIN-TKQHRGCY678\MyAccount'. ) )
Posted
Updated 11-Dec-13 6:16am
v4
Comments
Peter Leow 11-Dec-13 9:53am    
The answer lies within the error message.
KururuLABO 11-Dec-13 10:33am    
I try check user and my account or db it true all but can't login
Morgan Estes 11-Dec-13 12:34pm    
A couple of questions:

1) Are you using the PDO_SQLSRV driver? (Better yet, which driver are you using?)
2) Have you tried connecting to the db outside of PHP with that username/password combo to verify that they work?
ZurdoDev 11-Dec-13 13:00pm    
Login failed for the user. You need to setup proper permissions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900