Send data to Database

-1

I have a database with the following primary and foreign keys

tb_detalhe_trabalhador
    id
    tb_funcoes_id
    tb_trabalhador_id

tb_equipamentos
    id
    tb_trabalhador_id

tb_funcoes
    id

tb_trabalhador
    id

My last table to fill is tb_equipamentos . And give me the error: Column tb_trabalhador_id cannot be null.

I have this field:

$sqlinsert = "INSERT INTO tb_equipamentos VALUES(0, NULL, '" . $MaquinaNumero1 . "',

This null is tb_trabalhador_id

    
asked by anonymous 07.02.2014 / 17:55

2 answers

2

This error is a message from the database saying that you are trying to provide a null value to a field that can not be null.

As I understand it, you are trying to put a record in the equipment table, and one field in that record is the worker ID. Please check your code to confirm that you are filling this field. If not, edit your question and put the next error code so we can help you better.

    
07.02.2014 / 17:57
0

You are trying to insert NULL into a column that is NOT NULL , if you really want to assign NULL to this column, the way is to change the column to allow NULL .

ALTER TABLE equipamentos MODIFY tb_trabalhador_id INT NULL;
    
07.02.2014 / 18:04