Page 1 of 1
MsSQL connect
Posted: Thu Aug 02, 2007 9:58 am
by user___
Hi guys,
I have a remote MsSQL server and my php is properly configured to use MsSQL ext but I can not connect to that server. This is my code:
Code: Select all
$myServer = "***.***.***.***, 1433";//I have also tried the same server without port
$myUser = "user";
$myPass = "pass";
//Connect
$s = mssql_connect($myServer, $myUser, $myPass) or die("Unable to connect to server: $myServer");
and I get:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: ***.***.***.***, 1433 in C:\www\mssql.php on line 10
Unable to connect to server: ***.***.***.***, 1433
.
Do you have any ideas why I get that warning and I can not connect to the server.
try with navicat
Posted: Thu Aug 02, 2007 1:04 pm
by yacahuma
download navicat and try to connect to your mysql server from there. If you can , then you should have no problems.
I just mention this to make sure that you have the right permissions to connect remotely
Posted: Thu Aug 02, 2007 2:00 pm
by miro_igov
yacahuma, he asks about MSSQL, navicat does not support it.
It looks like the MSSql server is down or you use wrong user/pass.
Reply
Posted: Thu Aug 02, 2007 4:40 pm
by user___
Guys, thank you for your replies. I am not sure whether the server is down because a friend of mine connects through MsSQL server running on his machine but if I try to do the same by using Php it is impossible for a connection to be initiated. I use the credentials that my friend uses for his server but I can not connect by using Php.
Posted: Thu Aug 02, 2007 6:41 pm
by RobertGonzalez
Can you connect to it through Enterprise Manager or some other client interface? Does your server have the necessary drivers to connect to MsSql database servers? Can you ping the IP address of the DB server?
Posted: Thu Aug 02, 2007 6:55 pm
by John Cartwright
Change your connection call to
Code: Select all
$s = mssql_connect($myServer, $myUser, $myPass) or die("Unable to connect to server: ". mysqli_connect_errno());
That should give you a bit more information
Posted: Thu Aug 02, 2007 7:05 pm
by RobertGonzalez
Or perhaps Jcart meant:
Code: Select all
<?php
$s = mssql_connect($myServer, $myUser, $myPass) or die("Unable to connect to server: ". mssql_get_last_message());
?>
As mysqli functions would probably not give you what you want.

Posted: Thu Aug 02, 2007 7:36 pm
by John Cartwright
Whoops, thanks Everah

Reply
Posted: Fri Aug 03, 2007 3:06 am
by user___
Thank you guys, but I still can not connect to the server but by creating a simple ODBC connection I connect successfully so I suppose that there is nothing wrong with the server.
Do you have any suggestions?
BTW:I got the same output when I updated my query as you suggested.
Posted: Fri Aug 03, 2007 4:04 pm
by RobertGonzalez
Try setting up a DSN. I think I did that once to connect to a SQL Server database.