Hi, I'm having some trouble while trying to read some data from a Microsoft Access database using PHP.
While I can establish a connection to the database, every SQL query I try and run produces an error saying it doesn't have the appriopriate read/write access. But I know that the username and password I'm logging in with have full data user rights in the Access database.
The exact error message I'm getting is:
PHP Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Record(s) cannot be read; no read permission on 'TestTable'., SQL state 42000 in SQLExecDirect in C:....ODBCTest.php
The php code I'm using is as follows:
<?php
$dbq = "C:...MyDatabase.mdb";
$connect = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbq", 'username', 'password');
if (!$connect){
echo "Connection to Database failed <br>";
}
else {
echo "Connection established <br>";
}
$query = "SELECT * FROM TestTable;";
perform the query
$result = odbc_exec($connect, $query);
if ($result){
echo "Query Executed";
}
else {
echo "Query failed ";
}
fetch the data from the database
while(odbc_fetch_row($result)){
$name = odbc_result($result, 1);
$desc = odbc_result($result, 2);
print("$name $desc\n");
echo "***";
}
close the connection
odbc_close($connect);
?>
I've also tried creating a System DSN to use in the odbc_connect, but it produces the same error.
Any help would be much appreciated.