0

我有一个需要更新的表单我收到一个 sql 错误。在我的类文件中看不到我的 sql 语句发生了什么。需要帮助找出问题所在。

public function update(){
    global $database;
$sql = "UPDATE ".self::$table_name." SET when = '{$database->mysql_prep($this->when)}', where = '{$database->mysql_prep($this->where)}', howmuch = '{$database->mysql_prep($this->howmuch)}', contact = '{$database->mysql_prep($this->contact)}', daytimephone = '{$database->mysql_prep($this->daytimephone)}', emailqueries = '{$database->mysql_prep($this->emailqueries)}', websiteurl = '{$database->mysql_prep($this->websiteurl)}', description = '{$database->mysql_prep($this->description)}' WHERE id='{$database->mysql_prep($this->id)}'";
    $database->query($sql);
    return ($database->affected_rows() == 1) ? true:false;
}
4

1 回答 1

5

WHENWHERE是 MySQL 中的保留关键字。如果您需要将它们用作字段名称,请将它们括在反引号中:

`where`
`when`
于 2013-03-07T20:36:42.010 回答