Page 1 of 1

Problems in accessing MSSQL DB in PHP

Posted: Fri Apr 30, 2010 6:19 am
by pedrosacosta
Hi,

I'm trying to connect to a MSSQL database, but I get always unable to connect error. From my examples, you can see that I've tried every possible ways. :banghead:

The connection string from my sql client to the DB that I'm using is:
jdbc:jtds:sqlserver://10.217.80.205/MOPTeste;instance=cpifo;user=sa;password=cpifo

The code is working on Linux and the MSSQL is in a remote server.

The php code that I've is:

Code: Select all

<?php
(...)
//$sqllink = mssql_connect('10.217.80.205\CPIFO', 'sa', 'xxxxx');
$sqllink = mssql_connect('10.217.80.205', 'sa', 'xxxxx');
mssql_select_db('MOPTeste', $sqllink);

//$connStr = "sqlserver://sa:cpifo@10.217.80.205/MOPTeste";
//$connStr = "mssql://10.217.80.205/MOPTeste;instance=cpifo;user=sa;password=xxxxx";

//$sqllink = & MDB2::factory ( $dsn );
//$sqllink = & MDB2::connect ( $connStr )
//$dsn = array(
//    'phptype'  => 'mssql',
//    'username' => 'sa',
//    'password' => 'xxxxx',
//    'hostspec' => '10.217.80.205',
//    'database' => 'MOPTeste',
//);
//$sqllink = mssql_connect ( '10.217.80.205', 'sa', 'xxxxx' );
//mssql_select_db('MOPTeste', $sqllink);
//$db = DB::connect($connStr);

//$sqllink = & MDB2::connect ( $connStr );

?>
The error is:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 10.217.80.205 in /usr/local/www/data/mediacapital/lib/mssql.connection.php on line 34
As you can see from the commented code, I've tried every possible ways but the error is always the same.
The php5-mssql is installed.

How can I connect to the MSSQL DB?


thanks,
PSC