" UPDATE cms_content WHERE title ='主页" SET值=?"

时间:2014-04-28 15:47:19

标签: php mysqli

Lisa再次......如前所述,我正在建立一个系统,我想从数据库中加载内容,在我的AdminCP中我希望用户能够编辑内容,所以这就是我和#39;在changecontent.php中做:

if(isset($_POST['change_content'])) {
  $name = $_POST['content'];
  $errorscontent = $users->changeContent($text);
}

另一个文件:

    public function changeContent($text) {
    $errorscontent = array();
    $stmt = $this->mysqli->prepare("UPDATE cms_content WHERE title='homepage' SET text = ? ");
    $stmt->bind_param('s', $text);
    $stmt->execute();
    $stmt->close();
    $errorsslide[] = "<div class='alert alert-success'><button type='button' class='close' data-dismiss='alert'>x</button><strong>Success!</strong> Homepage content Changed successfully!</div>";
    return $errorscontent;
}

有谁知道我做错了什么?

莉莎

1 个答案:

答案 0 :(得分:2)

SET必须在您的查询中WHERE之前:

$stmt = $this->mysqli->prepare("UPDATE cms_content WHERE title='homepage' SET text = ? ");

应该是:

$stmt = $this->mysqli->prepare("UPDATE cms_content SET text = ? WHERE title='homepage' ");