PHP Sybase Extension

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I would like to use PHP's Sybase extension.  I am running my development
area on Windows under IIS.  When I enable the Sybase extension, I get a
message that indicates the extension didn't load.  After doing some digging
I have learned that in order for the Sybase extension to work
(php_sybase_ct.dll) I need libct.dll.

After Googling libct.dll and php_sybase_ct.dll and following several
threads, it appears that many people have had the same problem and come to
the same conclusion but no where did I find the information on where to
actually find libct.dll.  A search of the Sybase web site didn't yield
anything either.

Can anyone enlighten me as to what I need to install and more importantly,
where to get it from in order to get past this obstacle?



Mike Walsh - mike_walsh at

Re: PHP Sybase Extension wrote:
Quoted text here. Click to load it

If you were developing on Unix/Linux, I would suggest using freetds for the
low-level library. On Windows, it might be better to use the PHP ODBC
extension instead of the PHP sybase_ct extension.  Can your application use
ODBC instead? But the general answer to your question is that the low-level
library like libct.dll (or ODBC) has to come with the database software.
No, Sybase doesn't make it available separately as far as I know, and in
fact they don't even make it easy to find out how to buy it (apart from
being included in the database product). But if your Windows box can talk
to the database (with Sybase central, for example) then it already has the
low-level ODBC drivers from Sybase, and PHP should be able to use those
with the ODBC extension.

Re: PHP Sybase Extension

Quoted text here. Click to load it

[ ... snipped ... ]

Quoted text here. Click to load it
Quoted text here. Click to load it

Can you elaborate on freetds?  The application is developed on a Windows
environment but will be deployed on a Sun so I actually need to solve both

I have actually started looking into the ODBC solution and have been able to
create a connection via Excel so I assume I can use the same datasource for
PHP.  However, I am struggling with how exactly to make this work.

I have set up an ODBC Data Source using Windows XP's Data Source (ODBC)
Control Panel utility.  I am able to connect to the database without any
problem.  I have given this datasource a name "Sample Data Source".

Now how would I create the proper connection with PHP?  I am using PEAR DB
and did the following:

//The hostname that has the Database
define("DB_HOSTNAME", "");
define("DB_PORT", "1000");

//The username and password
define("DB_USERNAME", "db_username");
define("DB_PASSWORD", "db_password");

//The DB name to use
define("DB_NAME", "sample_database");

//The DB DSN
define("DB_DSN", "odbc://" . DB_USERNAME . ":" . DB_PASSWORD . "@" .
DB_HOSTNAME . ":" . DB_PORT . "/" . DB_NAME) ;

$dbh = DB::connect(CQ_DB_DSN, true) ;

if (DB::isError($dbh))
    die(sprintf("%s(%s):  %s", basename(__FILE__), __LINE__,
$dbh->getMessage())) ;
    print "Database connection successful." ;

$dbh->disconnect() ;

The values in the PHP defines are the same as those I used to create the
ODBC connection via the Windows Control Panel.  Should my DSN reference the
name I used to create the ODBC connection?  What would a valid DSN then look

Thanks for any guidance.


Mike Walsh - mike_walsh at

Re: PHP Sybase Extension wrote:
Quoted text here. Click to load it

I can't help with the ODBC part because I haven't used it. I have used
freetds. Home site is and project site is /
This is an open-source implementation of the TDS protocol, which was
developed by Sybase and also used by Microsoft. Freetds includes 3
libraries which aim to be call-compatible with Sybase's CT-lib, DB-lib, and
ODBC library. I've found freetds to be very usable, although the developers
still consider it "alpha" test. I use freetds with the PHP sybase-ct extension.

Don't forget that there are two Sybase databases, too: ASA (a.k.a. SQL
Anywhere) and ASE. There are differences but freetds talks to both. I'm
using freetds on Linux to talk to ASA (running on Netware, if you can
believe it).

Re: PHP Sybase Extension

You need to get the sybase client libary (or install the client on the
webserver where php runs).

Site Timeline