这也是我的代码。我不知道到底发生了什么。我希望有人会帮助我。先感谢您。 :(
<!--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();
?>
答案 0 :(得分:0)
错误非常清楚&#34;变量数量与参数数量不匹配&#34;。
你的&#34; $stmt->bind_param()
&#34;应该有六个变量,因为你在&#34; $mysqli->prepare()
&#34;中的6个位置引用了变量。声明。
答案 1 :(得分:0)
如果要更新或更改id,则应再传递一个参数/参数。
如果您不想更新ID,请执行以下操作:
$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'];
希望它有所帮助!