I am accessing an access database file using PHP on centos.
I am getting this error:
SQLSTATE[01000] SQLDriverConnect: 0 [unixODBC][Driver Manager]Can't open lib 'Microsoft Access Driver (*.mdb, *.accdb)' : file not found
That's what my code looks like:
<?php
print_r(PDO::getAvailableDrivers());
$dbName = "/var/www/html/crontest/Active.accdb";
echo $dbName."<br/>";
if(!file_exists($dbName)){
die('Error finding access database');
}
try
{
// Connection to ms access
$conn = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=".$dbName.";Uid=; Pwd=;");
$sql = "select * from Folio";
$rs = $conn->query($sql);
while($result = $rs->fetch())
{
echo $result[0].": ".$result[1]."<br />";
}
}catch (PDOException $e) {
echo $e->getMessage();
}
?>
and here is the output, you can see the pdo driver is there.
Array ( [0] => mysql [1] => odbc [2] => sqlite ) /var/www/html/crontest/Active.accdb
SQLSTATE[01000] SQLDriverConnect: 0 [unixODBC][Driver Manager]Can't open lib 'Microsoft Access Driver (*.mdb, *.accdb)' : file not found