chrscote Posted November 15, 2014 Share Posted November 15, 2014 (edited) 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 November 15, 2014 by chrscote Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/ Share on other sites More sharing options...
QuickOldCar Posted November 15, 2014 Share Posted November 15, 2014 You may need to use the 32 bit version of wamp Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/#findComment-1496670 Share on other sites More sharing options...
Ch0cu3r Posted November 15, 2014 Share Posted November 15, 2014 Try changing MS to Microsoft Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/#findComment-1496681 Share on other sites More sharing options...
QuickOldCar Posted November 15, 2014 Share Posted November 15, 2014 Or this odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/#findComment-1496690 Share on other sites More sharing options...
chrscote Posted November 18, 2014 Author Share Posted November 18, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/#findComment-1496952 Share on other sites More sharing options...
mikosiko Posted November 18, 2014 Share Posted November 18, 2014 look for and enable the php_pdo_odbc extension on php.ini restart your webserver an try again Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/#findComment-1496955 Share on other sites More sharing options...
chrscote Posted November 18, 2014 Author Share Posted November 18, 2014 Thank you mikosiko! I think that did the trick! At least it didn't give me the error. I'll try running the rest of the code in my page. Chris Quote Link to comment https://forums.phpfreaks.com/topic/292486-error-using-pdo-to-connect-to-access-db/#findComment-1496958 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.