Connection could not be established.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Connection could not be established.

Post by zyntrax »

Hi i am running an iis server with php and i got mssql extension, but i get an error when i try to connect to it with php:

Connection could not be established. Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [codé] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Inloggningen misslyckades f�r anv�ndaren FB\exalell. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Inloggningen misslyckades f�r anv�ndaren FB\exalell. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [codé] => 18456 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Inloggningen misslyckades f�r anv�ndaren FB\exalell. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Inloggningen misslyckades f�r anv�ndaren FB\exalell. ) )

It's complaing about the user but the user is dbowner.

This is the connection i use:

Code: Select all

$connectionInfo = array('Database'=>'fb_intra', 'UID'=>'FB\exalell', 'PWD'=>'pw'); 
$conn = sqlsrv_connect( "localhost\FB_INTRA", $connectionInfo);
if( $conn )
{
     echo "Connection established.\n";
}
else
{
     echo "Connection could not be established.\n";
     die( print_r( sqlsrv_errors(), true));
}	
I need help :(
prensil
Forum Newbie
Posts: 15
Joined: Tue Apr 26, 2011 8:38 am
Location: Ahmedabad
Contact:

Re: Connection could not be established.

Post by prensil »

try to use try...catch block like this:

Code: Select all

try{
      $conn = sqlsrv_connect( "localhost\FB_INTRA", $connectionInfo);
}catch(Exception $e){
    echo "<pre>";
    print_r($e);
    echo "</pre>";
    die;
}
May be the details description would help you.
zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Re: Connection could not be established.

Post by zyntrax »

Hi i tried, but it didn't catch anything.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Connection could not be established.

Post by John Cartwright »

28000 generally means the user supplied credentials failed to authenticate.
zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Re: Connection could not be established.

Post by zyntrax »

Ok what can i do about it?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Connection could not be established.

Post by John Cartwright »

zyntrax wrote:Ok what can i do about it?
You can get the correct authentication details from your host.
Post Reply