0
foreach ($checkArray as $key => $value) {

    $deleteUserStmt=$user_home->runQuery("DELETE FROM users WHERE userID = '".$key."' " AND " '".$value."'=1");

$deleteUserStmt->execute();
}

Am getting error:

Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' at line 1

$checkArray $key is userID and value is true or false. RunQuery method working with other queries.

So I think I have problem with query syntax?

chris85
  • 23,846
  • 7
  • 34
  • 51
Darius92
  • 301
  • 5
  • 21

1 Answers1

0

Query should be like this, dont put single quotes for the column names:
"DELETE FROM users WHERE userID = '$key' AND $value='1'"

rahul
  • 841
  • 1
  • 8
  • 18