0

Hello everyone?! When I change the value of my texboxes, I have this kind of error. Click to see the image.

And also here's my code. I don't know exactly what happened to it. I hope someone will help me with this. Thank you in advance. :(

<!--Update-->
<?php
  include "config.php";
  include "header.php";
  if(isset($_GET['u'])):
    if(isset($_POST['bts'])):
      $stmt = $mysqli->prepare("UPDATE personal SET id_personal=?, name=?, date=?, datepaid=?, amount=? WHERE id_personal=?");
      $stmt->bind_param('sssss', $id, $en, $date, $dp, $amnt);

      $id = $_POST['id'];
      $en = $_POST['en'];
      $date = $_POST['date'];
      $dp = $_POST['dp'];
      $amnt = $_POST['amnt'];

      if($stmt->execute()):
        echo "<script>location.href='index.php'</script>";
      else:
        echo "<script>alert('".$stmt->error."')</script>";
      endif;
    endif;
    $res = $mysqli->query("SELECT * FROM personal WHERE id_personal=".$_GET['u']);
    $row = $res->fetch_assoc();
?>

2 Answers2

0

The error is pretty much clear "Number of variables doesn't match number of parameters".

Your "$stmt->bind_param()" should have six variables,as you have referred variables at 6 places in "$mysqli->prepare()" statement.

Dinesh Belkare
  • 639
  • 8
  • 24
0

If you want to update or change id, then you should pass one more argument/parameter.

If you don't want to update ID then do the following:

  $stmt = $mysqli->prepare("UPDATE personal SET name=?, date=?, datepaid=?, amount=? WHERE id_personal=?");
  $stmt->bind_param('sssss', $en, $date, $dp, $amnt, $id);


  $en = $_POST['en'];
  $date = $_POST['date'];
  $dp = $_POST['dp'];
  $amnt = $_POST['amnt'];
  $id = $_POST['id'];

Hope it helps!

Harshil Doshi
  • 3,497
  • 3
  • 14
  • 37