Khashayar Ghamati
Khashayar Ghamati

Reputation: 368

update query not working

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();
          }
}

Upvotes: 0

Views: 92

Answers (1)

0x6C77
0x6C77

Reputation: 939

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

Upvotes: 1

Related Questions