UPDATE表与AJAX PHP没有初始化

im calling my AJAX functioin like this:

for (i = 0; i < remove.length; i++) {

    remove[i].addEventListener("click", function () {
        removeName = $(this).attr("id");

        $.ajax({
            type: "POST",
            url: "ajax.php",
            data: {deleteName: removeName}
        });
    });

}

In my ajax.php i have a function like this:

  if (filter_input(INPUT_POST, 'deleteName') != "") {
    $messageManager->deleteMessages(filter_input(INPUT_POST, 'deleteName'));
}

My deleteMessages() function looks like this:

public function deleteMessages($deleteName) {
    $sql = 'UPDATE ' . self::TABLE . ' SET rdelete=? WHERE receiver = ? AND sender=? OR sdelete=? WHERE receiver=? AND sender=?';
    $stmt = $this->dbh->prepare($sql);
    $stmt->execute(array(1, $_SESSION['user']->getName(), $deleteName, 1, $deleteName, $_SESSION['user']->getName()));
}

I have tried to use file_put_contents() in the deleteMessages() function to check if it gets accessed, but there is no file being created.

The variable that AJAX is sending, is indeed filled with the desired string. But some how in the ajax.php the POST is not being recognized... but only for "deleteName", everything else works fine.

Is my syntax wrong? im lost!

Actually i want to set rdelete=1 where receiver=me and sender=friend and set sdelete=1 where receiver=friend and sender=me

Your SQL is wrong. You have TWO where clauses, which is illegal.

WHERE receiver = ? AND sender=? OR sdelete=? WHERE receiver=? AND sender=?
^^^^--- clause #1                            ^^^^^---clause #2

It should be something more like:

WHERE ((receiver = ?) AND (sender = ?)) OR (sdelete =1) OR  ((receiver =? AND (sender = ?))

Note the extra () sets. You've got and and or clauses in there, which means you'll have to use () to enforce the logic evaluation order. The above is my best guess as to what you're trying to accomplish, but probably isn't what you really want.

And if you had even bare bones error handling on your DB calls, you'd have been informed about the syntax errors. By default, MySQLi and PDO simply default to silent failure, and returning boolean false. Never EVER assume success. Always assume failure, check for failure, and treat success as a pleasant surprise.