Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Do PHP can read and write data to MS Access database?

Posted on 2005-03-20
Medium Priority
Last Modified: 2010-05-18
Hi all,

All also know that PHP + MySQL is the perfect suite. But since some reason, I am using MS Access for my web site's database...... since the web host haven't provide a MySQL DB for free, just have one ODBC Access DB

Now, I want to ask, do php also can using Access for DB, if it can how to connect to it, make recordset? Mainly, I just need read some data from the Access DB, not need to write back to the Access DB. How to do it??

Can anyone can make the code for me to reference? Since I am new in programming ....

Also want to learn more about PHP4/5, where to starting???? If not buy a book.

Question by:explorer1979
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

drakkarnoir earned 120 total points
ID: 13586658
Learn more about PHP @ or

For the MS Access, here's a quickie to get you started:

$connect = odbc_connect("your_db_name0rz", "your_username", "your_password"); // connect

$query = "SELECT column,column2 FROM users"; // select column and column2 from users table

$result = odbc_exec($connect, $query); // do the query

while(odbc_fetch_array($result)) { // go get it!
$column = odbc_result($result, "column");
$column1 = odbc_result($result, "column2");
print("column: $column and column2: $column2\n");


LVL 16

Expert Comment

ID: 13586680
<<Also want to learn more about PHP4/5, where to starting???? If not buy a book.>>

search the internet for tutorials

another example:

$db = odbc_connect("YourDatabasePointer","YourUsername","YourPassword");
$rResult = odbc_exec ($db,"SELECT * FROM YourTableName");
<table border="1" width="100%">
while (($aRow = odbc_fetch_array($rResult)) !== False)
      <td align="center"><?php echo $aRow['id']; ?></td>
      <td align="center"><?php echo $aRow['firstname']." ". $aRow['lastname'];?></td>
      <td align="center"><?php echo $aRow['address']; ?></td>
      <td align="center"><?php echo $aRow['age']; ?></td>

this example uses a ms access db with the above field. it displays all records in db in table


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question