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:

    Digg Del.icio.us StumbleUpon Reddit Twitter RSS

If you're new here, you may want to subscribe to my RSS feed. You may copy or publish this article to your blog or other site as long you give credit link back to this site article. Thanks for visiting my blog!