Vebut Posted November 19, 2009 Share Posted November 19, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/ Share on other sites More sharing options...
ram4nd Posted November 19, 2009 Share Posted November 19, 2009 here is a tutorial, maybe you will find it useful http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.htmlwill find it useful Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/#findComment-961108 Share on other sites More sharing options...
JustLikeIcarus Posted November 19, 2009 Share Posted November 19, 2009 Try changing your path to C:\\xampp\\htdocs\\access\\test.mdb Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/#findComment-961117 Share on other sites More sharing options...
Vebut Posted November 19, 2009 Author Share Posted November 19, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/#findComment-961308 Share on other sites More sharing options...
JustLikeIcarus Posted November 19, 2009 Share Posted November 19, 2009 Yeah there are some lines in your php.ini file you need to uncomment. Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/#findComment-961312 Share on other sites More sharing options...
Vebut Posted November 19, 2009 Author Share Posted November 19, 2009 Yeah there are some lines in your php.ini file you need to uncomment. I uncommented the 'extension=php_pdo_odbc.dll' and now it seems to work just fine. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/#findComment-961314 Share on other sites More sharing options...
Vebut Posted November 20, 2009 Author Share Posted November 20, 2009 I can't seem to connect to a public database using the http address as dbq parameter. Quote Link to comment https://forums.phpfreaks.com/topic/182151-solved-pdo-connect-to-microsoft-access-database/#findComment-961749 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.