Jump to content

Recommended Posts

I am using WAMP server for my PHP Server and am trying to connect to an Access Database with the extension of accdb, but I keep getting the error "could not find driver". Here is the code I'm trying to run:

 

$dbName = $_SERVER["DOCUMENT_ROOT"]."/Ridley/RLCompRepair.accdb";

if (!file_exists($dbName)) {

     die("Could not find database file.");

}

try {

     $db = new PDO("odbc:Driver={MS Access Database (*.mdb, *.accdb)};Dbq=$dbName");

} catch (PDOException $e) {

     echo "Error: ".$e->getMessage();

}

 

I have enabled the php_pdo_odbc extension, so I'm pretty sure this is not the problem. Could someone please let me know what is wrong?

 

Chris

Edited by chrscote
Link to comment
https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/
Share on other sites

I have changed my $db line to: 

 

$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};;Dbq=$dbName");

 

but I am still getting the same error message when I echo getMessage() on the PDOException. Here is a list of all the extensions I have enabled:

php_curl

php_gd2

php_mbstring

php_mssql

php_mysql

php_mysqli

php_pdo_mssql

php_pdo_mysql

php_pdo_sqlite

 

I assumed that the mssql was the extension that needs to be set to handle Access, am I correct in that assumption. And just to be absolutely clear, I am using WAMP Version 2.4 with PHP 5.4.16.

 

Any and all help is greatly appreciated.

 

Thank you in advance,

Chris

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.