I have the following code in delete_thread.php:
<?php
include_once 'mysqli.php';
$query = 'DELETE FROM Thread
WHERE thread_id = ?';
$delete_thread_statement = $mysqli->prepare($query);
$delete_thread_statement->bind_param('i', $delete_thread_id);
$query = 'DELETE FROM Reaction
WHERE thread_id = ?';
$delete_reactions_statement = $mysqli->prepare($query);
$delete_reactions_statement->bind_param('i', $delete_thread_id);
function delete_thread($thread_id){
global $delete_thread_id;
global $delete_thread_statement;
global $delete_reactions_statement;
$delete_thread_id = $thread_id;
$delete_thread_statement->execute();
$delete_reactions_statement->execute();
$GLOBALS['rg']->addView($thread_id);
}
?>
When I call delete_thread from another file (that has included the delete_thread.php file of course), the given thread id's are output (see last line of the function) to the page, but the corresponding records are not deleted.
Do you have any idea what's wrong?