|Posted: 11/03/2009, 7:26 AM
Are you using php and trying to connect to an MS SQL database?
Suffering from this error message?
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server:...
I have seen many threads of others who have also had problems connecting using php to an MSSQL server.
Here is a description of the problem:
I am trying to connect to an MSSQL server database. My OS is Vista, I have WAMP server running with PHP 5.2.9-1 and the php_mssql extension is enabled.
I have created a system DSN in the Windows ODBC data source administrator (Microsoft SQL Native Client Version 09.00.4035).
(Use ANSI quoted identifiers - enabled
Use ANSI nulls, paddings and warnings - enabled
Perform translation for character data - enabled). It tests successfully.
Using this ODBC data source name in my connection properties (No persistent connection) it is able to see the database and works in design mode (I can select tables & Fields using Wizards etc).
As soon as I publish the project I get the following error in my browser:
"Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: ANDYJAMES\INTERPRISE in C:\wamp\www\testmssql\db_mssql.php on line 60
Database error: Cannot connect to mssql Database
Here is useful information that I found on the WAMPSERVER site that helped me resolve it:
unable to connect to mssql server
Posted by: Tanx0r (---.adsl.wanadoo.nl)
Date: June 11, 2008 10:12PM
Here is how to do it
1. Stop all WAMP services and the SQL Server (Express) service
2. Get ntwdblib.dll version 2000.80.194.0 (http://webzila.com/dll/1/ntwdblib.zip OR get a free copy of ntwdblib.dll by downloading MS SQL Server 2000 SP4 from Microsoft Website. It contains a copy of ntwdblib.dll version 2000.80.194.0 in the system directory). Copy and replace any other versions of this file to the following locations:
a) Your PHP binaries folder (ie C:\wamp\bin\php\php5.2.6)
b) Your Apache binaries folder (ie C:\wamp\bin\apache\apache2.2.8\bin)
3. Configure SQL Server to accept TCP connections and Named Pipes through the SQL server configuration manager (yes you will need the client tools installed).
4. Configure SQL Server for Mixed mode authentication and remember the password you set for sa
5. Start the SQL Server Service
6. Edit your php.ini and set the mssql.secure_connection = On
7. Make sure your wamp folder has proper access rights (full control for 'everyone').
8. Start all services from the WAMP menu.
You can connect to your SQL Server instance like this:
$dbhandle = mssql_connect('.\SQLEXPRESS','username','password');
$db = mssql_select_db('databasename', $dbhandle);
Part of this was taken from some other forum.
Hoping this will help you.
I hope that is of help!
RAD tools for rich UI controls: