Send data to Database

Asked

Viewed 111 times

-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 be filled 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 that of tb_trabalhador_id

  • Despite several editions, your Portuguese is still unclear. Try to express yourself better, your sentences are poorly formed.

  • Post your code to make it easier to analyze the problem.

  • Idente the code of your posts please.

2 answers

2

This error is a database message saying that you are trying to provide a null value to a field that cannot be null.

From what I understand, you’re trying to put a record in the equipment table, and one field of that record is the worker ID. Check your code to confirm that you are filling in this field. Otherwise, edit your question and put the next error code so we can help you better.

0

You’re trying to insert NULL in 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;

Browser other questions tagged

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