PHP:Read Microsoft Access Database

Hi all, This article is sample php code on how to pull data from Microsoft Access Database, Anyway this code only works on windows hosting only, when you try in linux hosting you will get message Fatal error: Class ‘COM’ not found.

What is benefit to using this code? Last week I made simple SMS gateway in my personal computer then use Microsoft Access Database as my database. Now I need to show this database out into web page using PHP script. with this code it will be possible.

Just learn this code below it’s very simple, you can pull or entry data into your database.

$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 

// Microsoft Access connection string.
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\mydir\\mydir\\mydb.mdb");

// SQL statement to build recordset.
$rs = $conn->Execute("SELECT myfield FROM mytable");
echo "<p>Below is list of values in MYDB.MDB, MYTABLE table, MYFIELD field.</p>";

// Display all the values in the records set
while (!$rs->EOF) {
    $fv = $rs->Fields("myfield");
    echo "Value: ".$fv->value."<br>\n";

That is, and your’re done 🙂

Similar Posts:

1 thought on “PHP:Read Microsoft Access Database”

  1. Stars Without Makeup

    These are in fact wonderful ideas in concerning blogging.
    You have touched some good factors here. Any way keep up wrinting.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.