请帮我修改MySQL UPDATING
这是我更新记录的代码:
<?php
if ( isset($_GET['id'])) {
$id = $_GET['id'];
$sql = mysqli_query($link, "SELECT * FROM changelog WHERE id='".$_GET['id']."'");
$row = mysqli_fetch_array($sql);
}
if ( isset($_POST['novavsebina'])) {
$novavsebina = $_POST['novavsebina'];
$id = $_POST['id'];
$sql = mysqli_query($link, "UPDATE changelog SET vsebina = '" . $novavsebina . "' WHERE id='".$_POST['id']."', date='".$_POST['date']."'");
header('Location: changelog.php');
}
?>
<div class="container main">
<div class="row">
<div class="page-header">
<h1>Changelog <small>Urejanje</small></h1>
</div>
<form role="form" action="uredi.php" method="post" accept-charset="utf-8">
<textarea name="novavsebina"><?php echo $row['vsebina']; ?></textarea>
<input type="hidden" name="id" value="<?php echo $row['id'] ?>">
<input type="date" name="date" value="<?php echo $row['date']; ?>" placeholder="">
<button type="submit" style="margin-top: 20px" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> Dodaj</button>
</form>
</div>
</div>
当我尝试更新时,它不会更新,甚至不会给我错误...
答案 0 :(得分:4)
你得到错误。你只是没有检查它们。
您的查询语法错误:
"WHERE id='".$_POST['id']."', date='".$_POST['date']."'"
应该是
"WHERE id='".$_POST['id']."' AND date='".$_POST['date']."'"