LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-27-2011, 12:26 AM   #1
Aurorius
LQ Newbie
 
Registered: Feb 2007
Posts: 20

Rep: Reputation: 1
How can I connect to Sybase using FreeTDS?


My freetds.conf

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
My `sybase.php`:

PHP Code:
    <?php
    
    $server 
'myserver';
    
$user   'user';
    
$pwd    'pwd';
    
$db     'db';
    
    @
sybase_connect($server$user$pwd) or die('Cannot connect');
    
    echo 
"OK\n";
It works just fine when I ran it through CLI, `php sybase.php`. But it won't connect when I ran it through webserver. **Does anyone has any idea what's wrong with my code?**

I've also tried putting

Code:
putenv("FREETDSCONF=/usr/local/etc/freetds.conf");
but nothing happens, I've even tried putting wrong path to `freetds.conf` before `sybase_connect()` and the code will still run fine (using `php sybase.php` but not through webserver).

BTW, I got these errors everytime I restart my apache:

Code:
    <br />
    <b>Warning</b>:  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 <b>Unknown</b> on line <b>0</b><br />
    <br />
    <b>Warning</b>:  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 <b>Unknown</b> on line <b>0</b><br />
    <br />
    <b>Warning</b>:  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 <b>Unknown</b> on line <b>0</b><br />
    <br />
    <b>Warning</b>:  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 <b>Unknown</b> on line <b>0</b><br />
I didn't uncomment `;extension=php_sybase_ct.dll` in my `php.ini` since I'm working in Linux. I've checked my `phpinfo()` and I can see `sybase_ct` section in it. I built my PHP using these arguments:

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'
 
Old 01-27-2011, 12:34 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
So do you actually have a bunch of Windows .dll's trying to interface to Sybase on your Linux server? That can't be good

Q: Why do you believe you need FreeTDS at all? (I'm not arguing - maybe you do.)

Q: Is Sybase co-located on your Linux server, or is it on a remote host?

Q: Is this a paid version of Sybase? If so, have you contacted Sybase technical support?

Last edited by paulsm4; 01-27-2011 at 12:36 AM.
 
Old 01-27-2011, 01:08 AM   #3
Aurorius
LQ Newbie
 
Registered: Feb 2007
Posts: 20

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by paulsm4 View Post
So do you actually have a bunch of Windows .dll's trying to interface to Sybase on your Linux server? That can't be good

Q: Why do you believe you need FreeTDS at all? (I'm not arguing - maybe you do.)

Q: Is Sybase co-located on your Linux server, or is it on a remote host?

Q: Is this a paid version of Sybase? If so, have you contacted Sybase technical support?
1. I'm new to the whole Sybase thing, I'm just trying to get some data (just reading) from a remote server (not mine) which uses Sybase. From what I've gathered from Googling, it's the simplest way for me to make sure I can use sybase_connect() in PHP. I've tried db-lib which doesn't show in my phpinfo() at all, but I haven't tried the ODBC way. Ref: http://www.freetds.org/userguide/php.htm

2. It's located remotely.

3. It's a paid version. It's a very long process for me to gain the access to the server since it's not mine. I've to go through some bureaucracy problems just to get in the server. So, asking for more help would be my last step.
 
  


Reply

Tags
database, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 5 with FREETDS Manuel-H Slackware 2 01-14-2008 07:15 AM
RHEL v5 + FreeTDS + PHP & Sybase TEXT Fields Bladez Red Hat 0 10-17-2007 02:54 PM
FreeTDS nerver gives libtdsodbc.so crimsontide Linux - Software 2 11-03-2006 10:43 AM
FreeTDS akurtis Linux - Networking 0 08-01-2006 11:51 AM
FreeTDS Install Problem wizhuff Linux - Software 1 07-27-2005 01:45 PM


All times are GMT -5. The time now is 08:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration