Login failed for user '(null)' I need to connect remotely to MS SQL Server 2000 using php.I am using the following codes:$dbhost = "IP address of server"; $dbuser = "username"; $dbpass = "password";mssql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to $db");But I keep getting the following errorHP Warning: mssql_connect() [function.mssql-connect]: message: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. (severity 14).I have already set mixed mode authentication on the server, but it did not help.Please help
I know little or nothing about php, but I am very familar with this error. This error normally has to do with when you are trying to connect using windows authentication and the remote user authentication is not being correctly passed to SQL Server. Normally happens when the remote user is not authenticated to IIS using Kerberos, so IIS is unable to pass on the remote user credentials to SQL Server. Since you seem to want to use SQL Server authentication, because you are passing a login and password, I would look at your IIS settings to verify that you are using SQL Server Authentication and not Windows Authentication. You might try to find out the setting of "mssql.secure_connection" option. I think if it is set to "on" then that means windows authentication.
Hello Greg, I tried setting mssql.secure_connection = Off, which means I am using SQL Authentication. Please correct me if I am wrong. Then I used a username and password in mssql_connect, but gives the same error. I also tried to mssql.secure_connection = On, and use mssql_connect without any username and password. But the problem persists.
Like I said using php is outside my scope of expertise. Here is a post that might help if you are using Apache as your web server. http://www.phpbuilder.com/board/archive/index.php/t-10265344.html
Perhaps the database was moved to another server, without the appropriate steps to move the logins. Try exec sp_change_users_login 'auto_fix', login from QA - it will tell you on the Messages tab if an orphaned user was fixed.