mssql_connect, odbc_connect error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dejvos
Forum Contributor
Posts: 122
Joined: Tue Mar 10, 2009 8:40 am

mssql_connect, odbc_connect error

Post by dejvos »

Hi,

I've problem with connecting to a remote MSSQL database. I'm trying it with both ways mssql_connect() and odbc_connect() and every time a get same error.
For mssql_connect()
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 192.168.1.100 in /var/www/localhost/htdocs/pokus.php on line 14
and for odbc_connect()
Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/localhost/htdocs/pokus.php on line 17
The script is:

Code: Select all

 
<?php
 
$x = mssql_connect($server,$user,$psswd);
if(!$x) echo 'M:'.mssql_get_last_message();
odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$db;",$user,$psswd);
?>
 
 
I've tried MSSQL with tsql and result is:

Code: Select all

locale is "C"
locale charset is "ANSI_X3.4-1968"
Msg 20009, Level 9, State 0, Server OpenClient, Line 0
Server is unavailable or does not exist.
There was a problem connecting to the server
It's pain in my neck, because I don't know MSSQL almost nothing and I need to get some suggestions of where could be a problem. Couldn't it be because of missing of a some library? Which librery? Bad ODBC set up?

Many thanks for EVERY suggestion!
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Re: mssql_connect, odbc_connect error

Post by Ollie Saunders »

I'd use a client application to see if you can actually connect to that database at all. Is the database not running or perhaps firewalled?
dejvos
Forum Contributor
Posts: 122
Joined: Tue Mar 10, 2009 8:40 am

Re: mssql_connect, odbc_connect error

Post by dejvos »

It's solved ... it was a bad setup of a sever and someone forgot to open the 1433 port. Damned I've been solving it whole day. I've askign provider status of Firewall for a million times and he tolds that me that everithing is OK for 999 999 times.
Post Reply