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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.