PDO dblib driver loaded, but not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

PDO dblib driver loaded, but not working

Post by RobertGonzalez »

Can anyone tell me why this code:

Code: Select all

<?php
print_r(PDO::getAvailableDrivers());
?>
which produces this output

Code: Select all

Array
(
    [0] => dblib
    [1] => mysql
    [2] => odbc
    [3] => sqlite
)
would, when called according to the manual, result in this code:

Code: Select all

<?php
try {
	$dbh = new PDO("dblib:host=hostname;dbname=dbname", "user", "password");
	echo 'We have a database connection;';
} catch (PDOException $e) {
	echo "Failed to get DB handle: " . $e->getMessage();
	exit;
}
?>
Returning this message:
Failed to get DB handle: SQLSTATE[] (null) (severity 0)
If the drivers are there, and I can connect to the database with the native database functions, why can I not connect with PDO? The database in question is Sybase. The client is installed and running, the sybase_* functions are working correctly, but for some reason PDO will not talk to it. PDO connects with no problem to MySQL.
Post Reply