Field 'Hash' does not have a default value

1

When I try to insert into a table this error appears Field 'Hash' doesn't have a default value

mysqli_query($conn, "SET SQL_MODE = ''; INSERT INTO ".SQL_TABELA."('Chave', 'Nome', 'Categoria', 'Tamanho', 'Link', 'Hash', 'Tipo', 'Parceiro') VALUES ('".$chave."', '".$name."', '".$category."', '".$size."', '".$link."', '".$hash."', '".$type."', '".$parceiro."')") or die(mysqli_error($conn));

Note: I already tried to remove the SET SQL_MODE = '';

    
asked by anonymous 31.03.2017 / 17:32

2 answers

2

You need to set a default value for the Hash column, for example:

ALTER TABLE Tabela MODIFY COLUMN Hash VARCHAR(255) DEFAULT NULL;

If you use NOT NULL use '' instead of NULL :

ALTER TABLE Tabela MODIFY COLUMN Hash VARCHAR(255) NOT NULL DEFAULT '';

This will set a default value for the column, when no value is specified it will be used. Note to set VARCHAR(255) to your requirement.

    
31.03.2017 / 18:21
0

Try using the

set @@global.sql_mode=''; 

This will disable strict mode.

can also change through my.ini. search for sql-mode and delete whatever is enclosed in quotation marks "

If you change in my.ini you will need to restart your mysql

    
31.03.2017 / 17:41