Apache 2.4.7 on Ubuntu 14.04 will not connect to MSSQL through PHP 5.5

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:

#   $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same 
# name is found in the installation directory.  
#
# For information about the layout of this file and its settings, 
# see the freetds.conf manpage "man freetds.conf".  

# Global settings are overridden by those in a database
# server specific section
[global]
        # TDS protocol version
;   tds version = 4.2

    # Whether to write a TDSDUMP file for diagnostic purposes
    # (setting this to /tmp is insecure on a multi-user system)
;   dump file = /tmp/freetds.log
;   debug flags = 0xffff

    # Command and connection timeouts
;   timeout = 10
;   connect timeout = 10

    # If you get out-of-memory errors, it may mean that your client
    # is trying to allocate a huge buffer for a TEXT field.  
    # Try setting 'text size' to a more reasonable limit 
    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. , , , , .

+4
1

, Yii MySql MSSQL. ,

0

All Articles