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

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.

Who is Participating?
drakkarnoirConnect With a Mentor Commented:
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");


<<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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.