1

i can connect from client PC to SQL Server Express using the following creds. in mgnt sudio:

server: 192.168.44.96\sqldb
auth: windows auth
user name: domain\user
pw: 1234!

Have a LAMP server trying to connect to the above SQL server, here's what the PHP looks like:

$server = '192.168.44.96\sqldb';
$username = 'domain\user';
$password = '1234!';
$database = 'testing123';
$connection = mssql_connect($server, $username, $password);
if($connection != FALSE){
    echo "Connected to the database server OK<br />";
}
else {
    die("Couldn't connect" . mssql_get_last_message());
}

if(mssql_select_db($database, $connection)){
    echo "Selected $database ok<br />";
}
    else {
    die('Failed to select DB');
}

the page displays 'couldn't connect' and the error.log says "unable to connect ot server: 192.168.44.96".

I have also set mssql.secure_connection = On in php.ini and restarted apache2.

any thoughts?

thanks!

1
  • We did this at my workplace, and we ended up hosting PHP on a windows box because theres no good drivers for MSSQL on Linux. We got it working but it took 30 secs to connect etc.. Commented May 21, 2012 at 21:52

2 Answers 2

1

I can't comment on the PHP part, I only know SQL Server.
But I can tell you: That's not how Windows authentication works.
You can't use Windows authentication and then pass user name and password explicitly to the server. You need to do one of these:

  1. Use SQL Server authentication and pass user name and password explicitly
  2. Use Windows authentication and do not pass user name and password - you will connect automatically with the active Windows user.

Since you're using a Linux server, I'm pretty sure that you can't use Windows authentication. So you have to use SQL authentication (which needs to be enabled on a fresh SQL Server installation), and you have to create an user on the SQL Server.

Sign up to request clarification or add additional context in comments.

3 Comments

is there any way to modify the current sql server instance to use mixed mode auth?
Yes, see this SO question: stackoverflow.com/questions/1393654/…
awesome! changed to mixed mode, added an sql user, connected using sql auth and the new user creds. works great! Thanks!
0

If you have a default sqlexpress installation you probably need to configure your sql server to allow remote access connections. Also I don't know if you can connect with windows auth. At your sql server you can also setup sql authentication and use uid=;pwd=.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.