mysql错误:由于您的SQL语法错误,此时无法更新数据;查看与您的MariaDB服务器版本相对应的手册,以便使用“INTO”类别中的正确语法SET title =' Lenovo vibe p1m',description =' Smartphone'其中id ='在第1行
<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>
答案 0 :(得分:3)
$sql= "UPDATE category SET title= '$item', description= '$des' where id= '$id'";
更新时你不需要INTO,只需保留像这样的SQL
答案 1 :(得分:0)
要进行更新,语法为
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'