How to test if a MySQL query was successful in modifying database table data?

Solution 1:

You're currently only checking whether the SQL statement is correctly prepared, you're not checking whether it actually deleted the record.

Try:

...
echo ($delRecord->affected_rows > 0) ? 'true' : 'false';
$delRecord->close();

That doesn't address whether you're correctly checking the result string in your Javascript code - if that's a problem we'll need more information.

Solution 2:

You need to use mysqli->affected_rows() for checking if the query was successful (or you could use mysqli_stmt->execute()'s result value).

Taking your example, and modifying nothing but for the above:

if($cmd=="deleterec") {
    $deleteQuery = "DELETE FROM AUCTIONS1 WHERE ARTICLE_NO = ?";
    
    if ($delRecord = $con->prepare($deleteQuery)) {
        $delRecord->bind_param("s", $pk);
        $delRecord->execute();
    
    
        if ($delRecord->affected_rows > 0) {
            echo "true";
        } else {
            echo "false";
        }

        $delRecord->close();
    }
}

Solution 3:

Use the return value of mysqli_stmt->execute() to see if the query was executed successful.