I have some PHP code at the top of my index.php file of my apache2 server that attempts to open and retrieve data from an SQLite3 database.
But it is causing the page to simply be blank, whereas if I comment out the code I see my chart.js table content.
<?php
echo "1";
$db = new SQLite3('/var/www/html/mydb.db');
echo "2";
$result = ($db->query('SELECT * FROM data_table'));
$letters_stack = array();
$numbers_stack = array();
while ($res = $result->fetchArray(SQLITE3_ASSOC)){
$letter = $res["letters"];
$number = $res["numbers"];
array_push($letters_stack, $letter);
array_push($numbers_stack, $number);
}
$db->close();
echo "3";
?>
The error appears to be caused by the line
$db = new SQLite3('/var/www/html/mydb.db');
as I added the echo's in and '1' is shown on the page, but '2' is never shown.
This database definitely exists in that folder, and I can open it and manipulate it through the terminal, and I have had this exact code working in my other server.
I attempted to briefly open up the permissions on the /var/www/html folder using
chmod -R 777 /var/www/html
to see if that was the cause but didn't help.