What's the best way to access a MS Access database using PHP?

Posted by Jack Roscoe on Stack Overflow See other posts from Stack Overflow or by Jack Roscoe
Published on 2011-01-03T11:49:04Z Indexed on 2011/01/03 11:53 UTC
Read the original article Hit count: 186

Filed under:
|
|
|
|

Hi,

I need to access some data from an MS Access database and retrieve some data from it using PHP.

I've looked around the web, and found the following line which seems to correctly connect to the database:

$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\wamp\www\data\MYDB.mdb");

However, I have tried to retrieve some data in the following way:

$query = "SELECT pageid FROM pages_table";
$result = mysqli_query($conn, $query);

$amount_of_pages = 0;

if(mysqli_num_rows($result) <= 0)
  echo "No results found.";
else
    while($row = mysqli_fetch_array($result, MYSQL_ASSOC))
        $amount_of_pages++;

And was presented with the following errors:

Warning: mysqli_query() expects parameter 1 to be mysqli, object given in C:\wamp\www\data\index.php on line 19

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\data\index.php on line 23 No results found.

I don't really understand the connection to the Access database, is there something I should be doing differently?

Thanks in advance for any help.

© Stack Overflow or respective owner

Related posts about php

Related posts about sql