【发布时间】:2017-12-25 22:23:25
【问题描述】:
mysql 错误:此时无法更新数据,因为您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的 'INTO category SET title='Lenovo vibe p1m', description='Smartphone' where 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>
【问题讨论】:
标签: php mysql database mysqli sql-update