更新查询不工作
问题描述:
我试着写与PDO更新查询,但它不能正常工作更新查询不工作
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();
}
}
什么不行?任何错误,通知,...什么? – Naruto 2014-09-23 11:21:29
在查询中添加字段名称 – 2014-09-23 11:21:52
您不能使用参数(即'?')作为字段名称。 – isalgueiro 2014-09-23 11:24:46