title: How can I connect to Sybase using FreeTDS?
body: <p>My freetds.conf</p>
  
  <pre><code># /usr/local/etc/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
  
  # A typical Sybase server
  [egServer50]
      host = symachine.domain.com
      port = 5000
      tds version = 5.0
  
  # A typical Microsoft server
  [egServer70]
      host = ntmachine.domain.com
      port = 1433
      tds version = 7.0
  
  [myserver]
      host = myserver.com
      port = 5000
      tds version = 5.0
  </code></pre>
  
  <p>My <code>sybase.php</code>:</p>
  
  <pre><code>&lt;?php
  
  $server = 'myserver';
  $user   = 'user';
  $pwd    = 'pwd';
  $db     = 'db';
  
  @sybase_connect($server, $user, $pwd) or die('Cannot connect');
  
  echo "OK\n";
  </code></pre>
  
  <p>It works just fine when I ran it through CLI, <code>php sybase.php</code>. But it won't connect when I ran it through webserver. <strong>Does anyone has any idea what's wrong with my code?</strong></p>
  
  <p>I've also tried putting</p>
  
  <p><code>putenv("FREETDSCONF=/usr/local/etc/freetds.conf");</code></p>
  
  <p>but nothing happens, I've even tried putting wrong path to <code>freetds.conf</code> before <code>sybase_connect()</code> and the code will still run fine (using <code>php sybase.php</code> but not through webserver).</p>
  
  <p>BTW, I got these errors everytime I restart my apache:</p>
  
  <pre><code>&lt;br /&gt;
  &lt;b&gt;Warning&lt;/b&gt;:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/php_sybase_ct.dll' - /usr/lib/php/extensions/php_sybase_ct.dll: cannot open shared object file: No such file or directory in &lt;b&gt;Unknown&lt;/b&gt; on line &lt;b&gt;0&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Warning&lt;/b&gt;:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/php_sybase_ct.dll' - /usr/lib/php/extensions/php_sybase_ct.dll: cannot open shared object file: No such file or directory in &lt;b&gt;Unknown&lt;/b&gt; on line &lt;b&gt;0&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Warning&lt;/b&gt;:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/php_sybase_ct.dll' - /usr/lib/php/extensions/php_sybase_ct.dll: invalid ELF header in &lt;b&gt;Unknown&lt;/b&gt; on line &lt;b&gt;0&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Warning&lt;/b&gt;:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/php_sybase_ct.dll' - /usr/lib/php/extensions/php_sybase_ct.dll: invalid ELF header in &lt;b&gt;Unknown&lt;/b&gt; on line &lt;b&gt;0&lt;/b&gt;&lt;br /&gt;
  </code></pre>
  
  <p>I didn't uncomment <code>;extension=php_sybase_ct.dll</code> in my <code>php.ini</code> since I'm working in Linux. I've checked my <code>phpinfo()</code> and I can see <code>sybase_ct</code> section in it. I built my PHP using these arguments:</p>
  
  <pre><code>'./configure' '--with-apxs2=/usr/sbin/apxs' '--prefix=/usr' '--libdir=/usr/lib' '--with-libdir=lib' '--sysconfdir=/etc' '--disable-safe-mode' '--disable-magic-quotes' '--enable-zend-multibyte' '--enable-mbregex' '--enable-tokenizer=shared' '--with-config-file-scan-dir=/etc/php' '--with-config-file-path=/etc/httpd' '--enable-mod_charset' '--with-layout=PHP' '--enable-sigchild' '--enable-xml' '--with-libxml-dir=/usr' '--enable-simplexml' '--enable-spl' '--enable-filter' '--disable-debug' '--with-openssl=shared' '--with-pcre-regex=/usr' '--with-zlib=shared,/usr' '--enable-bcmath=shared' '--with-bz2=shared,/usr' '--enable-calendar=shared' '--enable-ctype=shared' '--with-curl=shared' '--with-curlwrappers' '--with-mcrypt=/usr' '--enable-dba=shared' '--with-gdbm=/usr' '--with-db4=/usr' '--enable-exif=shared' '--enable-ftp=shared' '--with-gd=shared' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--with-xpm-dir=/usr' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--enable-gd-native-ttf' '--enable-gd-jis-conv' '--with-gettext=shared,/usr' '--with-gmp=shared,/usr' '--with-iconv=shared' '--with-imap-ssl=/usr' '--with-imap=/usr/local/lib/c-client' '--with-ldap=shared' '--enable-mbstring=shared' '--enable-hash' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--enable-pdo=shared' '--with-pdo-mysql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--with-pspell=shared,/usr' '--with-enchant=shared,/usr' '--with-mm=/usr' '--enable-shmop=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--enable-sockets' '--with-sqlite=shared' '--enable-sqlite-utf8' '--with-regex=php' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--enable-wddx=shared' '--with-xsl=shared,/usr' '--enable-zip=shared' '--with-tsrm-pthreads' '--enable-shared=yes' '--enable-static=no' '--with-gnu-ld' '--with-pic' '--with-sybase-ct=/usr/local/' '--build=i486-slackware-linux'
  </code></pre>