Question

I am building a website using PHP on Somee Server(somee.com) and Microsoft SQL. Now I have a problem making connection between php and SQL.

Here is my connection code:

<?php
$serverName = "mssql.somee.com"; //serverName\instanceName
// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"myDB","UID"=>"myusername","PWD"=>"mypassword");
$conn = sqlsrv_connect( "mssql.somee.com", $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));} ?>

And it returns me this error:

Connection could not be established. Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'. ) [1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'jason_SQLLogin'. ) )

Anyone knows about it? Thanks very much. Really appreciate it.

Was it helpful?

Solution

If you say you have the correct username / pass, perhaps the server (some.com) is actively blocking connections to it.

Try using below steps -

  1. On SQL Server (of SOMEE) in Security, make sure that Server Authentication is set to SQL Server and Windows Authentication Mode. This allows SQL server to authenticate username and passwords.

  2. Configure Server firewall to allow connections to SQL server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top