'SQLSTATE [HY093]:无效参数编号:绑定变量数量与令牌数量不匹配'
问题描述:
我收到SQLSTATE [HY093]的错误:无效参数编号:绑定变量数量与令牌数量不匹配'SQLSTATE [HY093]:无效参数编号:绑定变量数量与令牌数量不匹配'
if (isset($_POST['cadastrar'])){
$nome = trim(strip_tags($_POST['nome']));
$usuario = trim(strip_tags($_POST['usuario']));
$email = trim(strip_tags($_POST['email']));
$senha = trim(strip_tags($_POST['senha']));
$cpf = trim(strip_tags($_POST['cpf']));
$rg = trim(strip_tags($_POST['rg']));
$select = "INSERT INTO registro (nome, usuario, email, senha, cpf, rg)
VALUES (:nome, :usuario, email, :senha, :cpf, :rg)";
try{
$result = $conexao->prepare($select);
$result->bindParam(':nome', $nome, PDO::PARAM_STR);
$result->bindParam(':usuario', $nome, PDO::PARAM_STR);
$result->bindParam(':senha', $nome, PDO::PARAM_STR);
$result->bindParam(':email', $nome, PDO::PARAM_STR);
$result->bindParam(':cpf', $nome, PDO::PARAM_STR);
$result->bindParam(':rg', $nome, PDO::PARAM_STR);
$result->execute();
$contar = $result->rowCount();
if($contar>0){
echo 'logado com sucesso';
}else{
echo "Os dados digitados estão incorretos";
}
}catch(PDOException $e){
echo $e;
}
}
答
您的查询
$select = "INSERT INTO registro (nome, usuario, email, senha, cpf, rg)
VALUES (:nome, :usuario, email, :senha, :cpf, :rg)";
后变化缺少:在电子邮件
$select = "INSERT INTO registro (nome, usuario, email, senha, cpf, rg)
VALUES (:nome, :usuario, :email, :senha, :cpf, :rg)";
查询中缺少':'。 – tkausl
您在查询中缺少'email'参数的':'。 – rickdenhaan