$db = db_connect();
$title = $_POST['post_title'];
$content = $_POST['post_content'];
$id = $_GET['post'];
$userId = $_GET['id'];
$query = "UPDATE post";
$query .= "SET title = $title, content=$content";
$query .= "WHERE id= $id";
$result = mysqli_query($db, $query);
//Error handling
if(!$result) {
echo "Query failed" . mysqli_error($connection);
}
else {
echo "Post updated";
}
db_disconnect($db);
查询失败,并且不会在phpmyadmin中更新。我看不到哪里出了问题,也没有给出错误消息。
发布于 2018-06-18 00:12:03
我不确定这是否是您的唯一的问题,但是您的query
中需要空格
// change this
$query = "UPDATE post";
$query .= "SET title = $title, content=$content";
$query .= "WHERE id= $id";
// to this
$query = "UPDATE post ";
$query .= "SET title = '$title', content='$content' ";
$query .= "WHERE id = '$id'";
https://stackoverflow.com/questions/50898328
复制相似问题