'SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌的数量不匹配' [英] 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens'

查看:67
本文介绍了'SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌的数量不匹配'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到SQLSTATE [HY093]错误:无效的参数编号:绑定变量的数量与令牌的数量不匹配

I am receiving the error of SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

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)";

这篇关于'SQLSTATE [HY093]:无效的参数编号:绑定变量的数量与令牌的数量不匹配'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆