INSTER MYSQL PHP PDO ERROR

Asked

Viewed 42 times

-1

I’m trying to make an Insert using PHP PDO, but it is always returning an error, which I am not able to solve

$insert = "INSERT INTO usuarios ('usuario', 'senha', 'telefone', 'email', 'tipo', 'status', 'nivel', 'hash') VALUES (:usuario, :senha, :telefone, :email, :tipo, :status, :nivel, :hash)";

    try{
        $result = $conexao->prepare($insert);
        $result->bindParam(':usuario', $usuario, PDO::PARAM_STR);
        $result->bindParam(':senha', $senha, PDO::PARAM_STR);
        $result->bindParam(':telefone', $telefone, PDO::PARAM_STR);
        $result->bindParam(':email', $email, PDO::PARAM_STR);
        $result->bindParam(':tipo', $tipo, PDO::PARAM_STR);
        $result->bindParam(':status', $status, PDO::PARAM_STR);
        $result->bindParam(':nivel', $nivel, PDO::PARAM_STR);
        $result->bindParam(':hash', $hash, PDO::PARAM_STR); 
        $result->execute();
        $contar = $result->rowCount();
        if($contar>0){
            $ret['status'] = "OK";
        }else{
            $ret['status'] = "ERRO";
        }
    }catch(PDOException $e){
        echo $e;
    }

and is returning the following error:

Pdoexception: SQLSTATE[42000]: Syntax error or access Violation: 1064 You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near ''user', 'password', 'phone', 'email', 'type', 'status', 'nivel', 'hash') VALU' at line 1 in /var/www/html/trocadex/src/php/cadastro.php:32 Stack trace: #0 /var/www/html/trocadex/src/php/cadastro.php(32): Pdostatement->execute() #1 {main}null

1 answer

2


do not need quotes in the columns "INSERT INTO usuarios (user, password, phone, email, type, status, level, hash) VALUES (:user, :password, :phone, :email, :type, :status, :nivel, :hash)"

Browser other questions tagged

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