更新错误。 SQLSTATE [HY093]:参数号无效

时间:2017-05-16 07:06:44

标签: php mysql pdo

  require_once '../app/config.php';



if (!empty($_POST['update'])) {


$sql = "UPDATE web_usr SET 
               email = :email, 
               fname = :fname, 
               lname = :lname, 
               web_usr = :web_usr,
               usr_note = :usr_note, 
               avatar = :avatar, 
               usr_skill = :usr_skill 
               WHERE id = :id";


$stmt = $conn->prepare($sql);

$stmt->bindParam(':email', $email, PDO::PARAM_STR);
$stmt->bindParam(':fname', $fname, PDO::PARAM_STR);
$stmt->bindParam(':lname', $lname, PDO::PARAM_STR);
$stmt->bindParam(':web_usr', $web_usr, PDO::PARAM_STR);
$stmt->bindParam(':usr_note', $usr_note, PDO::PARAM_STR);
$stmt->bindParam(':avatar', $avatar, PDO::PARAM_STR);
$stmt->bindParam(':usr_skill', $usr_skill, PDO::PARAM_STR);

//Execute the statement and insert the new account.
$result = $stmt->execute();

//If the signup process is succesful.
if($result) {
  echo "Succesed";
} else {
    echo "gagal";

    }
  }

致命错误:在C:\ xampp \ htdocs \ otakutangerang_admin \ c_action.php中,消息'SQLSTATE [HY093]:无效参数号'未捕获异常'PDOException':33堆栈跟踪:#0 C:\ xampp \ htdocs \ otakutangerang_admin \ c_action.php(33):在第33行的C:\ xampp \ htdocs \ otakutangerang_admin \ c_action.php中抛出PDOStatement-> execute()#1 {main}

1 个答案:

答案 0 :(得分:1)

你也错过了

$stmt->bindParam(':id', $id, PDO::PARAM_INT );