I am trying to connect to a remote MSSQL server using the platforms listed in the header. I have FreeTDS and all related ODBC packages. Here is my freetds.conf:
[global]
; tds version = 4.2
; dump file = /tmp/freetds.log
; debug flags = 0xffff
; timeout = 10
; connect timeout = 10
text size = 64512
[DEVSQL]
host = x.x.x.x
instance = DEVSQL
tds version = 8.0
Here is my odbc.ini:
[ODBC Data Sources]
DEVSQL = FreeTDS Connection Server
[DEVSQL]
Description = MSSQL Server
Driver = freetds
ServerName = DEVSQL
Database = test
TDS_Version = 8.0
Here is my PHP code:
<?php
$dbname = "test";
$servername = "DEVSQL";
$username = "myuser";
$password = "mypassword";
try{
$db = new PDO('odbc:Driver=FreeTDS; Server='.$servername.'; Database='.$dbname.'; UID='.$username.'; PWD='.$password.';');
Database='.$dbname.'; UID='.$username.'; PWD='.$password.';');
}
catch(PDOException $exception){
die("Unable to open database.<br />Error message:<br /><br />$exception.");
}
echo '<h1>Successfully connected!</h1>';
?>
I can connect normally using the following commands in the terminal:
TDSVER=8.0 tsql -S devsql -U myuser -P mypassword
and:
isql -v devsql myuser mypassword
But when I look at index.php in FireFox, I get the following error:
exception "PDOException" with the message "SQLSTATE [08001] SQLDriverConnect: 0 [unixODBC] [FreeTDS] [SQL Server] Unable to connect to data source 'in / var / www / html / index.php: 16 Stack trace: # 0 / var / www / html / index.php (16): PDO → __ construct ('odbc: Driver = Fre ...') # 1 {} The main thing.
! , - sql linux box, php, . !
EDIT: : Ubuntu Apache Win7. Win7 SQL. , , , , .