Greetings Overflowers,
What is wrong with this PHP code:
<?php
define("DB_FILE", "sqlite:database.sql");
define("QUERY", "INSERT INTO Log VALUES (123)");
define("TIME_OUT", "60000");
function track() {
$db = new PDO(DB_FILE);
$db->exec(QUERY);
echo "OK!";
}
register_shutdown_function("track");
// sleep(TIME_OUT);
?>
Although “OK!” is printed when script is shutdown, nothing is really inserted into the database table. I tried calling track() directly and it did insert. Can not I do databases inside shutdown functions ?
Regards
First of all you should check if your query ran OK before outputting the OK! message. Use PDO::errorInfo to see what (if anything) went wrong.