当我向查询添加电子邮件时,数据库值不会更新。但没有电子邮件,一切正常。怪异。
这是我的更新查询:
if ($stmt = $mysqli->prepare("UPDATE signup_and_login_users_table SET fullname = ?, username = ?, email = ?
WHERE id=?"))
{
$stmt->bind_param("ssi", $fullname, $username, $id, $email);
$stmt->execute();
$stmt->close();
}
这是我的插页:
if ($stmt = $mysqli->prepare("INSERT signup_and_login_users_table (fullname, username, email) VALUES (?, ?, ?)"))
{
$stmt->bind_param("ss", $fullname, $username, $email);
$stmt->execute();
$stmt->close();
}
答案 0 :(得分:3)
你的参数订单应该是:$stmt->bind_param("sssi", $fullname, $username, $email, $id);
<?php
if ($stmt = $mysqli->prepare("UPDATE signup_and_login_users_table SET fullname = ?, username = ?, email = ? WHERE id = ?"))
{
$stmt->bind_param("sssi", $fullname, $username, $email, $id);
$stmt->execute();
$stmt->close();
}
?>
答案 1 :(得分:0)
您要绑定的参数应该是相同的顺序
试试这个
<?php
if ($stmt = $mysqli->prepare("UPDATE signup_and_login_users_table SET fullname = ?, username = ?, email = ? WHERE id = ?"))
{
$stmt->bind_param("sssi", $fullname, $username, $email, $id);
$stmt->execute();
$stmt->close();
}
?>
答案 2 :(得分:0)
问题是您的查询只有4个字段名称,但是您绑定了5个参数。你从查询中删除了“ssi”。
if ($stmt = $mysqli->prepare(
"INSERT signup_and_login_users_table (ssi, fullname, username, email) VALUES (?, ?, ?)")) {
假设“ssi”是字段名称