0

This is my first time using the php function odbc_connect(), I mostly work with php/mysql. The issue I am having is the function does not work. I have been reading up on the issue and the only resolution I can come up with is that either through php or apache the odbc connection has been disabled.

Here is what I know:

  1. I have php installed version 5.1.6 here is the configure command from php_info():

    './configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '-- target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '- -bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'

  2. The script I am running is a direct copy from IBM/Netezza Support(need log in):

    <?php
    //connect to database
    $connectionstring = odbc_connect("nps01", "admin", "password");
    $Query = "SELECT count(*) from _v_table";
    $queryexe = odbc_do($connectionstring, $Query);
    //disconnect from database
    odbc_close($connectionstring);
    ?>

  3. I can create a connection through linux isql using odbc:

    -bash-3.2$ isql NZSQL
    +---------------------------------------+
    | Connected! |
    | |
    | sql-statement |
    | help [tablename] |
    | quit |
    | |
    +---------------------------------------+

Is having both with/without unixODBC contradicting? I would appreciate any insight or trouble shooting advice.

powpow12
  • 587
  • 8
  • 13
  • 3
    You answered your own question. `--without-unixODBC` turns it off. Remove the "without" options and it should build with it (assuming you have the other libraries) – Cfreak Jun 14 '13 at 18:12
  • thank you for the quick response, can you step me through the removal process? Is there a way to check I have the right libraries? – powpow12 Jun 14 '13 at 19:15
  • is this a pre-built package? Not something you configured? If so then check if there's an addon for it through your package manager. It's probably called something like `php-odbc`. IMHO compiling PHP is a pain and it forces you to keep up updates yourself rather than through the package manager. – Cfreak Jun 14 '13 at 23:36
  • i believe so but I wasn't the one to install it. I will find out monday and get back to you. – powpow12 Jun 16 '13 at 11:49
  • 1
    we added php odbc and now odbc_connect function works. – powpow12 Jul 15 '13 at 16:36

0 Answers0