Could MySQL upgrade cause an INSERT statement to break? -
i upgraded mac , hence upgraded version of mysql. insert example trusted php book produces error. didn’t before. why?
i went mysql version 5.6.36 5.7.19. change in mysql versions cause insert break?
this example book “php , mysql web development”
this database:
describe customers; +------------+------------------+------+-----+---------+----------------+ | field | type | null | key | default | | +------------+------------------+------+-----+---------+----------------+ | customerid | int(10) unsigned | no | pri | null | auto_increment | | name | char(50) | no | | null | | | address | char(100) | no | | null | | | city | char(30) | no | | null | | +------------+------------------+------+-----+---------+----------------+
this insert issued bash terminal:
insert customers (name, city) values ('melissa jones', 'nar nar goon north');
this error:
error 1364 (hy000): field 'address' doesn't have default value
i error when running query via php
warning: mysqli_query(): empty query in /users/laptop/sites/...
what missing or doing wrong? thank you
not null - each row must contain value column, null values not allowed
https://www.w3schools.com/php/php_mysql_create_table.asp
as @barmar pointed @ comment, address
field have not null
attributes , should contain value when inserting row.
insert customers (name, address, city) values ('melissa jones', 'the_address', 'nar nar goon north');
there possibility make not
when writing script, should :
create table customers ( customerid int(10) unsigned auto_increment primary key, name char(50) not null, address char(100) null, city char(30) not null )
note : making name
, city
, address
char
type field not good. read why here : https://dev.mysql.com/doc/refman/5.7/en/char.html
Comments
Post a Comment