I'm really in need of assistance with this issue, ive been trying for days. I have an access database which i'm trying to query via PHP - i have come to this forum because after reading many posts and trying different things i am certain that this is some kind of issue on the server.
I have installed Microsoft access database engine, both 2010 and the 2007 version but whatever i try i get the same error message :
Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Connection<br/><b>Description:</b> Provider cannot be found.
I have uncommented all the relative lines in php.ini (after crawling through many stack overflow posts with the same issue) but with no success. Below is the code i am using in my php file.
<?php
// Create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
// Define the connection string and specify the database driver
$connStr = "PROVIDER=Microsoft.Ace.OLEDB.12.0;Data Source=".realpath("HS_BE.accdb").";";
// Open the connection to the database
$conn->open($connStr);
// Declare the SQL statement that will query the database
$query = "SELECT * FROM Accommodation";
// Execute the SQL statement and return records
$rs = $conn->execute($query);
$num_columns = $rs->Fields->Count();
echo $num_columns . "<br>";
for ($i=0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);
}
echo "<table>";
while (!$rs->EOF) // Carry on looping through while there are records
{
echo "<tr>";
for ($i=0; $i < $num_columns; $i++) {
echo "<td>" . $fld[$i]->value . "</td>";
}
echo "</tr>";
$rs->MoveNext(); // Move on to the next record
}
echo "</table>";
// Close the connection and recordset objects freeing up resources
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
Id be very grateful for some assistance!