PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, January 29, 2022

[FIXED] Mysql errors type #1067 - Invalid default value when

 January 29, 2022     mysql, mysql-workbench, phpmyadmin     No comments   

Issue

I got more errors when I export my table from Mysql Workbench6.3 and insert into my database by using Phpmyadmin.

   CREATE TABLE IF NOT EXISTS `loan`.`tb_banks` (
  `id` INT(10) NOT NULL AUTO_INCREMENT,
  `bank_name` VARCHAR(100) CHARACTER SET 'utf8' NOT NULL,
  `account_name` VARCHAR(100) CHARACTER SET 'utf8' NOT NULL,
  `account_number` VARCHAR(100) CHARACTER SET 'utf8' NOT NULL,
  `active` TINYINT(4) NOT NULL DEFAULT '1',
  `user_id` INT(11) NOT NULL,
  `created_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updated_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  CONSTRAINT `banks.user_id = users.id`
    FOREIGN KEY (`user_id`)
    REFERENCES `loan`.`tb_users` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 31
DEFAULT CHARACTER SET = utf8;

SHOW WARNINGS;
CREATE INDEX `banks_user_id_index` ON `loan`.`tb_banks` (`user_id` ASC);

SHOW WARNINGS;

This is my errors enter image description here


Solution

MySQL does not accept TIMESTAMP values that include a zero in the day or month column or values that are not a valid date. The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

More about this here : http://dev.mysql.com/doc/refman/5.7/en/datetime.html



Answered By - Andreea Dumitru
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing