RossM Posted March 3, 2009 Share Posted March 3, 2009 Hi People, This problem is doing my nut! I am trying to get a connect to my MsSQL server however it keeps erroring. I ahve tried the code: <?php function customError($errno, $errstr) { echo "<b>Error:</b> [$errno] $errstr"; } set_error_handler("customError"); mssql_connect("sqlserver", "username", "password"); ?> But says [2] mssql_connect() [function.mssql-connect]: Unable to connect to server: sqlserver Anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/147763-solved-connection-to-mssql-server/ Share on other sites More sharing options...
rhodesa Posted March 3, 2009 Share Posted March 3, 2009 is the server running on the same system or a remote system? if it's local, use 'localhost' for host or if it's remote, use the full hostname (aka sqlserver.yourdomain.com) or the IP address of the sql server Quote Link to comment https://forums.phpfreaks.com/topic/147763-solved-connection-to-mssql-server/#findComment-775649 Share on other sites More sharing options...
corbin Posted March 3, 2009 Share Posted March 3, 2009 You might also have to specify the instance name depending on the configuration of the server. For example: localhost\INSTACE1 Quote Link to comment https://forums.phpfreaks.com/topic/147763-solved-connection-to-mssql-server/#findComment-775824 Share on other sites More sharing options...
RossM Posted March 4, 2009 Author Share Posted March 4, 2009 Hi, Thanks for the replies. The sql server is on a remote machine within the same network. I tried [servername], [servername].domain.com and the ip address of the server and still says cannot connect. The sql server doesn't have an instance name. Any other suggestions? Thanks, Ross Quote Link to comment https://forums.phpfreaks.com/topic/147763-solved-connection-to-mssql-server/#findComment-776152 Share on other sites More sharing options...
RossM Posted March 4, 2009 Author Share Posted March 4, 2009 Figured it out. For future reference, this is how I did it: - Download the newest version of ntwdblib.DLL (version 2000.80.194.0 or greater to connect to SQL 2003 or higher) - In the php.ini file, make sure mssql.secure_connection is off if you want to use sql authentication - Reboot the server - Done! Quote Link to comment https://forums.phpfreaks.com/topic/147763-solved-connection-to-mssql-server/#findComment-776192 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.