Pdostatement::execute(): SQLSTATE[HY093]: Invalid Parameter number: Parameter was not defined

Asked

Viewed 46 times

0

I have a problem making an Insert in the base using PDO. PHP shows me this error. Searching, I saw that this error refers to the number of parameters that do not hit bindValues, for example:

INSERT INTO usuarios (nome, email, senha) VALUES (:nome, :email);

Or else:

INSERT INTO usuarios (nome, email, senha) VALUES (:nome, :email, senha);

But I’ve already reviewed all my code and I can’t find the error. Someone could help me?

Follows code:

$stmt = $conn->pdo->prepare("INSERT INTO
        usuarios (
            nome,
            email,
            senha,
            saldo_dindone,
            datacria,
            horacria, 
            status,
            foto_perfil,
            ativacao,
            hash_ativacao,
            facebook_id
        ) VALUES (
            :nome,
            :email,
            :senha,
            :saldo,
            :datacria,
            :horacria,
            :status,
            :foto_perfil,
            :ativacao,
            :hash_ativacao,
            :facebook_id
        )");

And the bindValue:

    $stmt->bindValue(':nome', $fbfullname);
    $stmt->bindValue(':email', $email);
    $stmt->bindValue(':senha', $seg_senha);
    $stmt->bindValue(':saldo', $saldo_inicial);
    $stmt->bindValue(':datacria', $data);
    $stmt->bindValue(':horacria', $hora);
    $stmt->bindValue(':status', 'pendentedados');
    $stmt->bindValue(':foto_perfil', $foto);
    $stmt->bindValue(':ativacao:', 1);
    $stmt->bindValue(':hash_ativacao', '0');
    $stmt->bindValue(':facebook_id', $fbid);
    $stmt->execute();

Thanks in advance!

EDIT

rray I know there’s a topic in the O.R. But if I had read my topic I would have seen that I looked for the problem and identified why my code was wrong, but I could not find which line was wrong in my code!

  • 1

    Your consultation has :ativacao your bind is :ativacao: has a : left over at the end.

  • 1

    Wow, that was it. It worked here. Thanks!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.