Jump to content

[SOLVED] PDO, Connect to Microsoft Access Database


Vebut

Recommended Posts

Hi,

I've been trying to connect to a .mdb file for some time now without success. Been following a couple of tutorials found on google but they all end up with the same error message.

 

<?php
$pdo = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\xampp\htdocs\access\test.mdb;Uid=Admin");
var_dump($pdo->errorInfo());
?>

 

I get this error message

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] SQLDriverConnect: -1044 [Microsoft][Driver for ODBC Microsoft Access] Invalid filename.' in C:\xampp\htdocs\access\index.php:3 Stack trace: #0 C:\xampp\htdocs\access\index.php(3): PDO->__construct('odbc:Driver={Mi...') #1 {main} thrown in C:\xampp\htdocs\access\index.php on line 3

 

What am I doing wrong?

// Daniel

here is a tutorial, maybe you will find it useful  http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.htmlwill find it useful

 

As you can see that is exactly where I got my code from. The DSN is identical.

 

@ JustLikeIcarus: I changed the directory separators to '/' instead and now that part seems to work just fine. Now I get this error message:

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in D:\_server\htdocs\access\index.php:2 Stack trace: #0 D:\_server\htdocs\access\index.php(2): PDO->__construct('odbc:Driver={Mi...') #1 {main} thrown in D:\_server\htdocs\access\index.php on line 2

 

Is there a driver I have to install before I can connect to msaccess files?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.