Uncaught exception 'PDOException' with message 'SQLSTATE [23000]: Integrity constraint violation: 1048

0

I'm trying to make a simple insertion into the database, as I've done several times, using PDO and I can not! What's wrong?

PHP:

<?php
include_once("con.php");

$pdo = conectar();

$data = file_get_contents("php://input");
$data = json_decode($data);

$opcao = $data->opcao;
$email = $data->email;
$senha = $data->senha;
$nome = $data->nome;
$usuario = $data->user;
$idempresa = $data->idempresa;

$insereUsuario=$pdo->prepare("INSERT INTO usuario (idusuario, usuario, senha, email, empresa_idempresa, nome)
                         VALUES (?, ?, ?, ?, ?, ?)");
$insereUsuario->bindValue(1, NULL);
$insereUsuario->bindValue(2, $usuario);
$insereUsuario->bindValue(3, $senha);
$insereUsuario->bindValue(4, $email);
$insereUsuario->bindValue(5, $idempresa);
$insereUsuario->bindValue(6, $nome);
$insereUsuario->execute();

Error message:

  

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE [23000]: Integrity constraint violation: 1048 Column' userid 'can not be null'

My table in the DB

    
asked by anonymous 06.01.2017 / 19:31

0 answers