[unixODBC-support] odbc_exec Never Returns

Jason Maitlen Jason.Maitlen at OntarioSystems.com
Mon May 11 23:53:16 BST 2009

I recently put FreeTDS and unixODBC on a linux box that previously had neither but was already running Apache and PHP without problem. I'm trying to connect to a MS SQL Server database. I was able to setup freetds.conf and successfully query with tsql. I am using the following odbcinst.ini:

Description  = v0.63 with protocol v8.0
Driver       = /usr/local/lib/libtdsodbc.so
UsageCount   = 1

and the following odbc.ini

Driver      = FreeTDS
Description = DataGatherer DB on spsql02
Trace       = No
Server      = spsql02
Port        = 1433
TDS_Version = 7.0
Database    = DataGatherer

I am able to query using isql successfully. 

I set environmental variable ODBCINI to my odbc.ini file path. Then I tried using the following PHP:

if ($dbResource = odbc_connect('DataGatherer','[username]','[password]')) {
    $strSQL = 'select * from ProductData';
    $result = odbc_exec($dbResource, $strSQL);
    if ($result) {
        $arrResults =  odbc_fetch_array($result);
    } else {
        echo 'false';
} else {
    echo 'false';

What I'm finding is that odbc_connect returns fine, but only if I use the correct credentials as expected. odbc_exec however never returns and I can't get the script to timeout or throw an error. 


Jason Maitlen

Application Developer, IT Desktop-Applications
Technology Department
Ontario Systems, LLC

Attention: This message and all attachments are private and may contain
information that is confidential and privileged. If you received this
message in error, please notify the sender by reply email and delete
the message immediately.

More information about the unixODBC-support mailing list