SQLSTATE [23000]: Integrity constraint violation

0

I have an employee table and address. The address is a foreign key of the employee, however, is giving the following error when I insert:

Exception 'PDOException' with message 'SQLSTATE [23000]: Integrity constraint violation: 1452 Can not add or update child row: a foreign key constraint fails

How do I resolve this?

$consulta = "INSERT INTO ENDERECO (FUNCIONARIO_FUN_CODIGO) 
    VALUES(:codigoFuncionario)";

    try{
        $resultado=$db_con->prepare($consulta);

        //$resultado->BindParam(':cep',$cep,PDO::PARAM_STR);
        $resultado->BindParam(':codigoFuncionario',$codigoFuncionario,PDO::PARAM_STR);


        $resultado->execute();
    
asked by anonymous 16.05.2017 / 21:32

0 answers