Using SQLite in PHP (using PDO), I have this code:
try {
$db = new PDO("sqlite:C:\Program Files\Spiceworks\db\spiceworks_prod.db");
echo "Done.<br /><b>";
$query = "SELECT id FROM Devices LIMIT 5";
echo "Results: ";
$result = $db->query($query);
while ($row = $result->fetchArray()) {
print_r($row)."|";
}
}
catch(PDOException $e) {
echo $e->getMessage();
}
But this does not output any data from SQL. I know there is data in the database and the connection is valid. If I change the request, I will say:
$query = "SELECT BLAHid FROM FakeDevices LIMIT 5";
Nothing changes. Nothing of SQL prints again, and I see no errors, although this is clearly an invalid SQL query.
In both situations, Finish and Results are printed in order. How to print SQL errors, for example, if the query is invalid?
source
share