Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mssql_connect() [function.mssql-connect]: Unable to connect to server:

Status
Not open for further replies.

hex6007

MIS
Sep 2, 2008
53
PH
hi guys,

pls do help me... problem when im trying to connect to my server im working in. below is the error that appear:

Error:
mssql_connect() [function.mssql-connect]: Unable to connect to server:

I tried running all the services of MSSQL. still got same error. i tried also installing the native client but still no responce.

But when i tried the link to the other workstation it works. how come is on my computer the link connection doesnt work.

pls help.


 
what is the configuration your using?
are you using wamp or xampp?
 
ok what is the code your using for your connection?

here is the sample im commonly using:

Code:
<?php
	$dbhost = 'localhost';
   	$dbuser = 'root';
  	$dbpass = '';
   	$db_name ='database';
     
   	$connection = mysql_connect($dbhost, $dbuser, $dbpass);
   	if (!$connection)
   	{
		die('Error connecting to mysql' . mysql_error());
   	}
   
   	mysql_select_db($db_name,$connection);

?>

save it as a php file and include it in the pages that needs database connection
hope it helps....
 
im using a MSSQL connection instead...

<?php

// Connection
$svr = 'localhost';
$user = 'username';
$pass = 'password';

// Establish Connection
mssql_connect($svr,$user,$pass)
or die ('Cannot Connect to MSSQL Server');
mssql_select_db('database');

?>
 
use the default user which is root
so on your line:

<?php

// Connection
$svr = 'localhost';
$user = 'root';
$pass = 'password';
$dbase = 'database';

// Establish Connection
mssql_connect($svr,$user,$pass)
or die ('Cannot Connect to MSSQL Server');
mssql_select_db('$dbase');


and i think your code does not contain the variable that contains the name of your database


?>
 
sorry mislois cause i change my connection variables to show the connection link...im connecting to a server unit. i tried it in other workstation its working only on my computer not working.
 
its probably the connection settings from your pc to the server just check it with your administrator
 
I have run into problems connecting to MS SQL Server 2005 with the built-in .dll's included in PHP. I'll look and see if I can remember what I did to fix it, but I think I ended up needing to get new libraries from Microsoft to get it to work.
 
Check the version of the ntwdblib.dll. It looks like PHP includes version 2000.2.8.0 but you need version 2000.80.194.0 or newer to connect to SQL Server 2003 and newer. You can download the new library from Microsoft and it looks like I put it in my PHP root, not the extensions directory like I would have expected.
 
Many thanks to all response posted on my concern. its now finely working... i downloaded the new version of the ntwdblib.dll file from microsoft.

thanks guys

best
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top