<?php
// The idea is the add formated errors information for developers to easier bugs detection.
$myfile = fopen("database_log.log", "r");
$db = new mysqli("localhost", "root","root","data");
if(!$db->query("SELECT")){
$timestamp = new DateTime();
$data_err = " {
\"title\": \" Select statement error \",
\"date_time\": ".$timestamp->getTimestamp().",
\"error\":\" ".$db->error." \"
} "; // Do more information
fwrite($myfile, $data_err); // writing data
}
// In separate file do file read and format it for good visual.
$db->close();
fclose($myfile);
?>