0

Im trying to write an update query with PDO but it's not work

for ($count = 0; $count < 4; $count++) {
        if (!trim($elements[$count])=='') {

                $query = "update servers set " . '?' . "=" . '?' . "where " . '?'  . "=" . '?';
                $pdo = new PDO($db->dsn, 'adp', 'pass');
                $stmt = $pdo->prepare($query);
                $stmt->bindParam(1, $index[$count]);
                $stmt->bindParam(2, $elements[$count]);
                $stmt->bindParam(3, $index[$count]);
                $stmt->bindParam(4, $ServerName);
                $stmt->execute();
          }
}
Mithun Satheesh
  • 27,240
  • 14
  • 77
  • 101

1 Answers1

1

Table and Column names cannot be replaced by parameters in PDO. See this answer for more details.

Community
  • 1
  • 1
0x6C77
  • 939
  • 3
  • 13
  • 36