Ubuntu – php5-mssql / freetds : can connect with tsql, not with php5-mssql

freetdsPHPsql serverUbuntu

i'm trying to set up an Ubuntu workstation for php development with php5-mssql.
First i compiled freetds-nightly 0.8.3 ( with –enable-msdblib ) and installed it to /usr/local/freetds , copying header files from the package to /usr/local/freetds/include

Then, I grabbed the php5 source with apt-get source php5, and compiled the mssql extension as follows:

phpize
cd ext/mssql
./configure --with-mssql=/usr/local/freetds
make
sudo install

this placed mssql.so in to my php extensions dir and php is loading the extension fine.
After all this i added my server in /usr/local/freetds/etc/freetds.conf:

[global]
    tds version = 7.0
    dump file = /tmp/freetds.log
    text size = 64512

[db-02]
host = XXXXX
port = 1433
tds version = 7.0

First of all, i wanted to use tds 8.0 but any value higher then 7.1 is ignored, which is strage since freetds on my mac ( built from macports with +mssql ) does 8.0 while being older. ( 0.8.2 i think )

Anyway, with this i can connect up to my sever with /usr/local/freetds/bin/tsql beautifully. NOT with php5-mssql..

here's some output from freetds.log ( this is all from the failed attempt )

log.c:196:Starting log file for FreeTDS 0.83.dev.20100710
    on 2010-07-13 11:17:23 with debug flags 0x4fff.
iconv.c:337:tds_iconv_open(0x91d3a98, UTF-8)
iconv.c:197:local name for ISO-8859-1 is ISO-8859-1
iconv.c:197:local name for UTF-8 is UTF-8
iconv.c:197:local name for UCS-2LE is UCS-2LE
iconv.c:197:local name for UCS-2BE is UCS-2BE
iconv.c:365:setting up conversions for client charset "UTF-8"
iconv.c:367:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:408:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
iconv.c:411:tds_iconv_open: done
net.c:225:Connecting to XXXX port 1433 (TDS version 7.0)
net.c:281:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:321:tds_open_socket() succeeded
util.c:156:Changed query state from DEAD to IDLE
login.c:771:quietly sending TDS 7+ login packet
token.c:328:tds_process_login_tokens()
net.c:608:Received header
0000 04 01 00 78 00 49 01 00-                        |...x.I..|

net.c:662:Received packet
0000 04 01 00 78 00 49 01 00-aa 64 00 18 48 00 00 01 |...x.I.. .d..H...|
0010 0e 1f 00 4c 00 6f 00 67-00 69 00 6e 00 20 00 66 |...L.o.g .i.n. .f|
0020 00 61 00 69 00 6c 00 65-00 64 00 20 00 66 00 6f |.a.i.l.e .d. .f.o|
0030 00 72 00 20 00 75 00 73-00 65 00 72 00 20 00 27 |.r. .u.s .e.r. .'|
0040 00 63 00 61 00 6c 00 76-00 69 00 6e 00 27 00 2e |.X.X.X.X .X.X.'..|
0050 00 0d 4e 00 45 00 54 00-4d 00 49 00 4e 00 49 00 |..Y.Y.Y. Y.Y.Y.Y.|
0060 4e 00 47 00 44 00 41 00-54 00 41 00 00 01 00 fd |Y.Y.D.A. T.A.....|
0070 02 00 00 00 00 00 00 00-                        |........|

token.c:337:looking for login token, got  aa(ERROR)
token.c:122:tds_process_default_tokens() marker is aa(ERROR)
token.c:2710:tds_process_msg() reading message 18456 from server
token.c:2783:tds_process_msg() calling client msg handler
dbutil.c:85:_dblib_handle_info_message(0x90180e8, 0x91d3a98, 0xbf8f56d0)
dbutil.c:86:msgno 18456: "Login failed for user 'XXXX'."
token.c:2796:tds_process_msg() returning TDS_SUCCEED
token.c:337:looking for login token, got  fd(DONE)
token.c:122:tds_process_default_tokens() marker is fd(DONE)
token.c:2461:tds_process_end: more_results = 0
        was_cancelled = 0
        error = 1
        done_count_valid = 0
token.c:2477:tds_process_end() state set to TDS_IDLE
token.c:2492:                rows_affected = 0
token.c:437:tds_process_login_tokens() returning TDS_FAIL
login.c:462:login packet accepted
util.c:156:Changed query state from IDLE to DEAD
util.c:331:tdserror(0x90180e8, 0x91d3a98, 20002, 0)
dblib.c:7861:dbperror(0x91d3378, 20002, 0)
dblib.c:7913:20002: "Adaptive Server connection failed"
dblib.c:7934:"Adaptive Server connection failed", client returns 2 (INT_CANCEL)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1415:dbclose(0x91d3378)
dblib.c:258:dblib_del_connection(0x997340, 0x91d3a98)
mem.c:615:tds_free_all_results()
dblib.c:305:dblib_release_tds_ctx(1)
dblib.c:5828:dbfreebuf(0x91d3378)
dblib.c:724:dbloginfree(0x91d2f90)
dblib.c:3985:dbsetlogintime(5)
dblib.c:3944:dbsettime(60)
dblib.c:698:dblogin(void)
dblib.c:4890:dberrhandle(0x81a1fd0)
dblib.c:4909:dbmsghandle(0x81a35d0)
dblib.c:746:dbsetlname(0x91d2f90, UTF-8, 10)
dblib.c:746:dbsetlname(0x91d2f90, PHP 5, 5)
dblib.c:1121:dbopen(0x91d2f90, 0x0, [microsoft])

( the same credentials get me in with tsql )

Any help is greatly appreciated.

thanks,
Andrew

ps: some tsql -C output

Compile-time settings (established with the "configure" script)
                            Version: freetds v0.83.dev.20100710
             freetds.conf directory: /usr/local/freetds/etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 5.0
                              iODBC: no
                           unixodbc: yes

Best Answer

Solved. Should've used the stable release.. 0.8.2 supports tds 8.0, 0.8.3 does not. duh.

which, by the way, still does not explain why i was able to connect up to my mssql server with tsql, using protocol 7.1, but not with php5-mssql.