Skip to Content.
Sympa Menu

freetds - Re: [freetds] Freetds works in commandline but not with apache/php

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: <eric.berg AT barclayscapital.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Freetds works in commandline but not with apache/php
  • Date: Mon, 31 Jan 2011 17:09:14 -0500

I found my self in this situation a while ago. It turned out that I still
had some Sybase stuff left over in my environment. Removing it fixed the
problem.

Check your LD_LIBRARY_PATH, and SYBASE environment variables. Make sure to
set them in the script that invokes apache as setting them in the apache
variables.conf file doesn't fully overwrite them.

Ultimately, resetting and/or unsetting them in our startup scripts did fix
this problem.

Eric

> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Johan
> Thorvaldsson
> Sent: Wednesday, January 19, 2011 10:17 AM
> To: freetds AT lists.ibiblio.org
> Subject: [freetds] Freetds works in commandline but not with
> apache/php
>
> I'm new to this maillist and I have completely got stucked
> when it comes to making a successful connection to mssql from
> a ubuntu server 10.10 (maverick).
>
> The connection works in bash with tsql, here is output of tsql -C
> Compile-time settings (established with the "configure" script)
> Version: freetds v0.82
> freetds.conf directory: /etc/freetds
> MS db-lib source compatibility: no
> Sybase binary compatibility: yes
> Thread safety: yes
> iconv library: yes
> TDS version: 4.2
> iODBC: no
> unixodbc: yes
>
> Some queries work like:
> SELECT ba.Bank_Account_ID, ba.Bank_Account_Type,
> ba.Bank_Account_Alias, bat.Description, bat.Currency FROM
> Bank_Accounts AS ba
> INNER JOIN Bank_Account_Type AS bat ON
> bat.ID = ba.Bank_Account_Type
> WHERE ba.Bank_Account_Owner_User_ID = '111222'
>
> But this do not work:
> SELECT
>
> Account_Users.*,Account_Users_Type.Description AS
> Account_Type_Description, Account_Users_Status.ViewVerificationProcess
> FROM Account_Users
> INNER JOIN Account_Users_Status
> ON Account_Users_Status.ID = Account_Users.Account_Status
> INNER JOIN Account_Users_Type
> ON Account_Users_Type.ID = Account_Users.Account_Type
> WHERE Account_Email = '<login>'
> AND Account_Password = 'md5-hash'
> AND Account_Users_Status.Access = 1
> AND
> Account_Users.FailedLogon_Counter < 3
>
> The last query returns nothing to the browser ( apache/php ).
> It works fine in Microsoft SQL Server Management Studio.
>
> Here is output of freetds.log:
>
> log.c:190:Starting log file for FreeTDS 0.82
> on 2011-01-19 15:13:21 with debug flags 0x4fff.
> iconv.c:197:names for ISO-8859-1: ISO-8859-1
> iconv.c:197:names for UTF-8: UTF-8
> iconv.c:197:names for UCS-2LE: UCS-2LE
> iconv.c:197:names for UCS-2BE: UCS-2BE
> iconv.c:363:iconv to convert client-side data to the
> "ANSI_X3.4-1968" character set
> iconv.c:516:tds_iconv_info_init: converting "US-ASCII"->"UCS-2LE"
> iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
> net.c:210:Connecting to 10.0.0.102 port 1433 (TDS version 8.0)
> net.c:264:tds_open_socket: connect(2) returned "Operation now
> in progress"
> net.c:303:tds_open_socket() succeeded
> util.c:162:Changed query state from DEAD to IDLE
> login.c:735:quietly sending TDS 7+ login packet
> token.c:312:tds_process_login_tokens()
> net.c:592:Received header
>
> On the query that fails the log ends with:
> dblib.c:1961:dbnextrow() dbresults_state = 2 (_DB_RES_RESULTSET_ROWS)
> token.c:495:tds_process_tokens(0x22b5f6d0, 0xbfbd8dfc, (nil), 0x1508)
> util.c:162:Changed query state from PENDING to READING
> token.c:510:processing result tokens. marker is fd(DONE)
> token.c:2201:tds_process_end: more_results = 0
> was_cancelled = 0
> error = 0
> done_count_valid = 1
> token.c:2217:tds_process_end() state set to TDS_IDLE
> util.c:162:Changed query state from READING to IDLE
> token.c:2232: rows_affected = 1
> util.c:110:logic error: cannot change query state from IDLE to PENDING
> dblib.c:2030:leaving dbnextrow() returning NO_MORE_ROWS
>
> I have configured freetds latest stable with:
> ./configure --prefix=/usr/local/freetds --with-tdsver=8.0
>
> And after that installed php with apt-get, and then
> recomplied the php modules mssql with:
> ./configure --with-mssql=/usr/local/freetds
> And copied mssql.so to php extension-folder. It turns up ok
> in phpinfo.
>
> Is there someone who could help me out here?
>
> Thanks
>
> Regards
> Johan
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
_______________________________________________

This e-mail may contain information that is confidential, privileged or
otherwise protected from disclosure. If you are not an intended recipient of
this e-mail, do not duplicate or redistribute it by any means. Please delete
it and any attachments and notify the sender that you have received it in
error. Unless specifically indicated, this e-mail is not an offer to buy or
sell or a solicitation to buy or sell any securities, investment products or
other financial product or service, an official confirmation of any
transaction, or an official statement of Barclays. Any views or opinions
presented are solely those of the author and do not necessarily represent
those of Barclays. This e-mail is subject to terms available at the following
link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent
to the foregoing. Barclays Capital is the investment banking division of
Barclays Bank PLC, a company registered in England (number 1026167) with its
registered office at 1 Churchill Place, London, E14 5HP. This email may
relate to or be sent from other members of the Barclays Group.
_______________________________________________




Archive powered by MHonArc 2.6.24.

Top of Page