[英]UPDATE query fails php mysql
$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);
The query fails and is not updated in phpmyadmin.查询失败且未在 phpmyadmin 中更新。 I can't see what is going wrong and no error message is given.
我看不出哪里出了问题,也没有给出错误消息。
I'm not sure if this is your only issue, but you need spaces in your query
我不确定这是否是您唯一的问题,但您的
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'";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.