0

我在尝试解决此查询时遇到了一点问题,如果在表单输入后单击提交按钮,这是页面上“必需”的脚本。该页面已经设置了 $connection 变量,并且值正在正确回显,尽管在第二个嵌套的“IF”语句中我仍然收到“错误”消息回显给我。任何人都可以帮忙吗?谢谢!

<?php
if ($_POST['firstname'] != "" && $_POST['lastname'] != "" && $_POST['email'] != "" && $_POST['position'] != "" && $_POST['building'] != "") {
    $iserid = htmlspecialchars($_COOKIE['userid']);
    $fname_input = htmlspecialchars($_POST['firstname']);
    $lname_input = htmlspecialchars($_POST['lastname']);
    $fullname_input = htmlspecialchars($_POST['firstname']) . " " . htmlspecialchars($_POST['lastname']);
    $email_input = htmlspecialchars($_POST['email']);
    $position_input = htmlspecialchars($_POST['position']);
    $building_input = 1;

    $update = $connection->prepare("UPDATE user SET first = ?, last = ?, full = ?, email = ?, position = ?, building = ? WHERE id =  ?") or trigger_error($connection->error);
    $update->bind_param("ssssssi",$fname_input, $lname_input, $fullname_input, $email_input, $position_input, $building_input, $userid);

    if ($update->execute) {
        echo "success";
        $update->close();
    } else {
        echo "fail";
        $update->close();
    }

} else {
    $error = "One or more of your fields was left blank. Please press back on you browser toolbar and try again or click here to close this message.";
}
?>
4

1 回答 1

2

改变

if($update->execute)

if($update->execute())
于 2013-01-10T15:12:17.013 回答