我有一个需要更新的表单我得到一个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;
}
答案 0 :(得分:5)
WHEN
和WHERE
是MySQL中的保留关键字。如果您需要将它们用作字段名称,请将它们包含在反引号中:
`where`
`when`