致命错误:未捕获的PDOException:SQLSTATE [HY093]:无效的参数编号: 参数未在/subdomeny/panel/public_html/pages/register.page.php:128
中定义堆栈跟踪:
#0 /subdomeny/panel/public_html/pages/register.page.php(128):PDOStatement-> execute(Array)
#1 /subdomeny/panel/public_html/index.php(108):include('/ subdomeny / pane ...')
在第128行的/subdomeny/panel/public_html/pages/register.page.php中抛出#2 {main}
此错误适用于此代码。如何解决此错误?
$insert
数组是
Array ([prefix] =>
[session_id] => session_id
[rules] => rules
[privacy-policy] => privacy-policy
[rodo] => rodo
[register_step1] => INSERT INTO users (session_id, rules, privacy-policy, rodo) VALUES (:session_id, :rules, :privacy-policy, :rodo) )
$_POST
数组是
Array(4) {["rules"]=> string(1) "1"
["privacy-policy"]=> string(1) "1"
["rodo"]=> string(1) "1"
["register"]=> string(6) "Accept" }
这是MySQL问题:
INSERT INTO users (session_id, rules, privacy-policy, rodo)
VALUES (:session_id, :rules, :privacy-policy, :rodo)
PHP 7,MySQL 5,Apache 2,HTML 5,CSS 3
$sql = $pdo->prepare($select['register']);
$sql->execute([$select['session_id']=> $_SESSION['sid']]);
$row = $sql->fetch(PDO::FETCH_ASSOC);
if($row['rules']&&$row['privacy-policy']&&$row['rodo']==true){
$register_template = $step_2;
}else{
$register_template = $step_1;
}
if(isset($_POST['register']) && !empty($_POST['register'])){
if(!empty($_POST['rules']&&$_POST['privacy-policy']&&$_POST['rodo'])){
if($_POST['rules']&&$_POST['privacy-policy']&&$_POST['rodo']=="1"){
var_dump($_POST);
$sql = $pdo->prepare($insert['register_step1']);
$sql->execute([
$insert['session_id']=> $_SESSION['sid'],
$insert['rules']=> $_POST['rules'],
$insert['privacy-policy']=> $_POST['privacy-policy'],
$insert['rodo']=> $_POST['rodo']
]);
//$insert['rodo']=> $_POST['rodo']
//$insert['privacy_policy']=> $_POST['privacy-policy']
//$insert['rules']=> $rules,
//$insert['privacy-policy']=> $privacy_policy,
//$insert['rodo']=> $rodo
//]);
$register_template = $step_2;
}
}else{
$register_template = 'Error';
}
}else{
$register_template = $step_1;
}
echo $register_template;