Microsoft Access Database

I would like to at least read, preferably read/write from/to an MS Access Database.

Is this possible and if so, how would you go about it?


William Kenny

If you want to use an Access database in your application, see

Otherwise, if you want to work with MS SQL server, you need to get the Microsoft SQL Server Driver for PHP and use this extension for your PHP code.
Samples about using it are available at

This is just what I was looking for too… :slight_smile:

Actually not quite what I was looking for - the ODBC method I believe assumes you have microsoft office and therefore access already installed on a pc or remote network basis - is there a way of using exeoutput for php directly with a microsoft access file, even if the user doesn’t have access installed eg in a similar way to how sqlite works with .sql files ?

Found this … -and-pecl/ but it is making a php extension (.so) first - not sure how it would work with exeoutput, nor how to make one for a windows system.(.dll). seems to reference UNIX / Linux servers only. Any ideas on how to directly use MS Access files with exeoutput would be helpful - even if it is possible.

Thanks for any help.

I’ll make some research about this. ExeOutput is for Windows, so .so extensions won’t work. You have to use DLL versions of PHP extensions.

Cheers… might be of use to other people to. in theory it should be possible. I am doing some research if my own as well - if all fails will just convert access database to mysql file and store that on a remote server with mysql, and access the database that way… but not really ideal.

After some research, it looks like the OBDC method does not require Microsoft Office, but a free add-on that is shipped by Microsoft: Microsoft Access Database Engine 2010 Redistributable
It can be downloaded from:

Explanation about using Access in PHP is available here:

You should enable this extension in ExeOutput:

and try:

<?php $dbName = $_SERVER"DOCUMENT_ROOT"] . "products\\products.mdb"; if (!file_exists($dbName)) { die("Could not find database file."); } $db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbName; Uid=; Pwd=;"); I'll make further tests when possible.

have you tried looking into ADODB? I used it to access *.accdb files, though I haven’t tried working into *.mdb files… Through it, I could use SQL commands to work trough the tables: really convenient!

I’m just now beginning to dabble with Access database files, so I haven’t learned the difference, nor the (dis)advantages between *.mdb and *.accdb access files… I came across this in a search for access db work and php… This php to exe thing looks pretty cool!

Cheers for the feedback…