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

I installed PHP on IIS. After configured I manage to connect to the MSSQL DB but there is a warning message. I have no idea what it means
(Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: (localhost) in C:\Inetpub\wwwroot\global.php on line 39).
risk-xAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

obareeyCommented:
are you sure your SQL server is running and give correct username/password to the function?
0
dwaynecharringtonCommented:
You've entered your username, password or hostname incorrectly. Check your details and try again. You might also need to connect to a specific port.
0
nplibCommented:
can you post your code?

other wise we are guessing.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

risk-xAuthor Commented:
This is my code. Thx

<?php

//$webhost = '';
//$internalhost = '';
$dbhost ='(localhost)';
$dbuser = 'sa';
$dbpasswd = 'sasa';
$dbname   = 'companylog';




if(!($s = mssql_connect($dbhost, $dbuser, $dbpasswd))) ;

if(!mssql_select_db($dbname)) ;



function mssql_setup() {
      global $dbhost;
      global $dbname;
      global $dbuser;
      global $dbpasswd;
}

?>
0
nplibCommented:
remove the brackets

$dbhost = 'localhost'
0
risk-xAuthor Commented:
after removed the brackets $dbhost = 'localhost' still the same warning message coming out.
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost in C:\Inetpub\wwwroot\global.php on line 30
I think is the setting I missed up. I tried in the ODBC but it show connection successfully connected to local DB. The same script I get from the server to my local computer but there is no such message coming out in the server.
0
nplibCommented:
is the mssql server running on the same server where this php file is being served?
0
risk-xAuthor Commented:
Yes  the mssql server running on the same server where the PHP file is being served. The PHP file is able coonect to the local DB. I just dont know why this message show out as the PHP file is connected with the local DB. There is no problem connect to the local DB, all the data from the DB able to pull out when served the php file. But there is a message showing out on the PHP file ."Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost"
0
obareeyCommented:
if you don't have problem reading data from the server and don't wanna see tihs message, you can put an @ before the function like this:
@mssql_connect(...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nplibCommented:
try using the actual IP address,

the MS SQL server may not accept localhost
0
risk-xAuthor Commented:
Thx a lot after i put @mssql_connect(... there is no warning message coming out alrdy. thx alot.
0
previewservicesCommented:
UPDATE!

I got the newest version of ntwdblib.DLL and i got a new message:

Error: [2] mssql_connect() [function.mssql-connect]: message: Login failed for user ''. The user is not associated with a trusted SQL Server connection. (severity 14)Error: [2] mssql_connect() [function.mssql-connect]: Unable to connect to server: 10.100.25.77
<?php
function customError($errno, $errstr)
{
	echo "<b>Error:</b> [$errno] $errstr";
}
 
set_error_handler("customError");
mssql_connect("xx.xx.xx.xx", "sa", "password");
?>

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.