-1

please help me with MySQL UPDATING

This is my code for updating records:

<?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>

When Im trying to update it won't update, not even give me error...

Sébastien
  • 11,860
  • 11
  • 58
  • 78

1 Answers1

4

You're getting errors. You're just not checking them.

Your query has a syntax error:

"WHERE id='".$_POST['id']."', date='".$_POST['date']."'"

should be

"WHERE id='".$_POST['id']."' AND date='".$_POST['date']."'"
John Conde
  • 217,595
  • 99
  • 455
  • 496