I am trying to run a php(7.2) query into a Microsoft Access Database over my network in a linux(Ubuntu 18.04) environment. I am using Nginx as my webserver and MDBTools as my driver. I set up an odbc.ini and odbcinst.ini DSN and have tried multiple ways of accessing the database. The 'dashboard' in my connection string is the name of my DSN.
This is my php querying script:
<html>
<body>
<?php
try{
$conn = new PDO('odbc:dashboard');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e){
die("Could not access database. <br> Error: $e");
}
echo "<p>";
$problems = $conn->prepare("SELECT * FROM tbl_PlanetSections");
$problems->execute();
$result = $problems->fetchColumn();
var_dump($result);
echo "</p>";
?>
</body>
</html>
When I run $ php Query.php in my terminal, the script executes as expected. When I load my page in the nginx webserver, I get this error:
PDOException: SQLSTATE[00000] SQLConnect: 0 in /srv/me/www/Query.php:8 Stack trace: #0 /srv/me/www/Query.php(8): PDO->__construct('odbc:dashboard') #1 {main}
Nothing after Line 8 (the line that I initialize the new PDO) executes due to the try/catch ending my script.
I have tried multiple different syntax's for the initialization line and nothing works. Am I missing something obvious or can this specific setup not be done?
Thanks