Php 为什么数据从表单提交时不能更新?

Php 为什么数据从表单提交时不能更新?,php,mysql,database,mysqli,sql-update,Php,Mysql,Database,Mysqli,Sql Update,mysql错误:由于SQL语法有错误,目前无法更新数据;检查与您的MariaDB服务器版本相对应的手册,以了解可在第1行中使用的接近“进入类别集title=”Lenovo vibe p1m',description=”Smartphone',其中id=”的正确语法 <html> <head><title>form</title> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.

mysql错误:由于SQL语法有错误,目前无法更新数据;检查与您的MariaDB服务器版本相对应的手册,以了解可在第1行中使用的接近“进入类别集title=”Lenovo vibe p1m',description=”Smartphone',其中id=”的正确语法

<html>
<head><title>form</title>
<link 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
 rel="stylesheet"/>
<script
  src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
  integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
  crossorigin="anonymous"></script>
</head>
<body>
<h1><center>Items UPdate</center></h1>

<div class="container">
<form method="POST" action=" ">
<div class="form-group row">
  <label for="example-number-input" class="col-md-2 col-form-label">Id of 
 item</label>
  <div class="col-md-10">
    <input class="form-control" type="number" value="1" id="example-number-`input" name="id">`
  </div>
</div>

 <div class="form-group row">
 <label for="example-text-input" class="col-md-2 col-form-label">Item</label>
  <div class="col-md-10">
    <input class="form-control" type="text" value="Lenovo vibe p1m" id="example-text-input" name="item">
  </div>
  </div>

<div class="form-group row">
  <label for="example-search-input" class="col-md-2 col-form-label">Description</label>
  <div class="col-md-10">
    <input class="form-control" type="search" name="description" value="Smartphone" id="example-search-input">
  </div>
</div>

  <button type="submit" class="btn btn-primary">Submit</button>
</form>

<script src= "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</form>
</div>

<?php 
print_r($_POST); 
$id = $_POST['id'];
$item = $_POST['item'];
$des = $_POST['description'];
include 'databaseConnect.php';

 $sql= "UPDATE INTO category SET title= '$item', description= '$des' where id= '$id'";
$query = mysqli_query($conn, $sql); 
if($query){
    echo "Data updated successfully";
  }else{
    echo "Data couldn't be updated at this moment because of " .mysqli_error($conn);
  }
?>
</body>
</html>

更新时不需要输入,只需像这样保留sql进行更新,语法如下

UPDATE table_name 
SET column1 = value1, column2 = value2, ...
WHERE condition; 
你的问题

UPDATE INTO category SET title= '$item', description= '$des' where id= '$id'
正确查询

UPDATE category SET title= '$item', description= '$des' where id= '$id'
UPDATE category SET title= '$item', description= '$des' where id= '$id'