How to connect to Sybase via PHP

zwiebelspaetzle picture zwiebelspaetzle · Jan 18, 2013 · Viewed 12.4k times · Source

I'm trying to connect to a Sybase database with PHP5. I believe I've successfully compiled PHP with PDO_DBLIB, as phpinfo() lists dblib under PDO drivers, and freetds as the pdo_dblib flavour.

However, when I try to test a connection, I get an error reading:

'PDOException' with message 'could not find driver'

I'm trying to connect to a server on my LAN with this code:

$dbh = new PDO("sybase:host=192.168.1.xxx;dbname=[database-name]", '[user]', '[pass]');

Any suggestions would be greatly appreciated!

Answer

gumaterror picture gumaterror · Jan 16, 2015

You should use dblib instead of sybase, like this:

$dbh = new PDO("dblib:host=192.168.1.xxx;dbname=[database-name]", '[user]', '[pass]');