SQLSTATE[HY000]: General error: 1366 Incorrect integer value:

I'm having some problems while using PDO. It all seems correct but I am getting this error

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ':permissao' for column 'permissao' at row 1\n

Here's the code that prints the output

$this->nome = $nome;
    $this->email = $email;

    $salt = $this->generateSalt();
    $permissao = 10;
            $activo = 0;
    #encripta chama a funcao para encriptar a password do utilizador
    $this->password = $this->pwdEncript($password, $salt);

 $params = array('nome'=>$this->nome,
                            'email'=>  $this->email, 
                            'password'=>  $this->password,

    $sql = "INSERT INTO sys_users(nome,email,password,salt,permissao,activo)

        $sth = $this->db->prepare($sql); 
    catch(PDOException $e)
        echo 'Erro ao inserir na base de dados'.$e->getMessage().'\n';

Permissao is an INT on mysql table.

Glad for any help given on this one ;)


Try this:

$sql = "INSERT INTO sys_users(nome,email,password,salt,permissao,activo)

Already said it in the comments, but it looks like you don't need the quotes around the placeholders. Just rely on the Prepared Statement mechanism to do it for you.

NOTE: For MySQL, PDO defaults to emulating prepared statements. For extra security you might want to set it up to use real prepared statements instead.

$pdo -> setAttribute (PDO::ATTR_EMULATE_PREPARES, false); 

Need Your Help

Running a WCF service before unit testing

c# wcf unit-testing

I have a VS 2010 solution that contains two projects: the first is a WCF service, and the second is a unit testing project, holding a reference to the service and testing the methods the service is

Running webserver and TCP server simultaneously

python web tcp flask

I have a webserver setup using Flask, and it works. In addition, I have a demo TCP server, which also works. I want them to run in the same process, so they can communicate; however, I am running i...