Problem inserting data php mysql ID

0

I have a problem inserting data into mysql due to table id.

Tb_Details_worker: id, Name, Function

$sqlinsert = "INSERT INTO tb_detalhe_trabalhador VALUES ('','".$Nome1."','".$Funcao1."') 
  

Error: Column count does not match value count at row 1

Do I have to by the mysql fields after the table name?

    
asked by anonymous 11.06.2014 / 22:56

1 answer

1

Correct:

$sqlinsert = "INSERT INTO tb_detalhe_trabalhador(nome, funcao) VALUES ('".$Nome1."','".$Funcao1."')";

When you have a auto_increment field, you do not have to enter it in the insert, but the required fields must be indicated. This insert that I showed you is a good practice, never forget to pass the fields.

    
11.06.2014 / 22:58