1

So i am just a beginner in all this php stuff. I know just the basics, and when i setting up the settings for my new table, I met the problem #1075. Before, i created one, almost similar to this one, and i don't see the differenc. Can you say me where is the problem and explain what is happening?

CREATE TABLE `try`.`testing` ( `id` INT NOT NULL AUTO_INCREMENT , `date` DATE NOT NULL , `text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , `text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ) ENGINE = MyISAM;

here is the code of my SQL Preview. I use phpMyAdmin, obviously. Please, help me. Thank, you)

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Godje
  • 404
  • 5
  • 15

4 Answers4

1

Try this

CREATE TABLE `testing` (
  `id` INT NOT NULL AUTO_INCREMENT, 
  `date` DATE NOT NULL, 
  `text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, 
  `text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE = MYISAM ;
PravinS
  • 2,640
  • 3
  • 21
  • 25
1

You have to declare your AUTO_INCREMENT field as a primary key or a key. So you have to add PRIMARY KEY (id) or KEY (id) to your CREATE TABLE statement:

CREATE TABLE `try`.`testing` ( 
`id` INT NOT NULL AUTO_INCREMENT, 
`date` DATE NOT NULL , 
`text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , 
`text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`id`) -- as primary key
KEY (`id`) -- or as key
) ENGINE = MyISAM;

Please also check:

https://stackoverflow.com/a/8114994/3647441

https://stackoverflow.com/a/14087703/3647441

Community
  • 1
  • 1
mario.van.zadel
  • 2,919
  • 14
  • 23
0

For an autoincrement field you should have some sort of index associated with it. eg: primary key which is missing

Nouphal.M
  • 6,304
  • 1
  • 17
  • 28
0

Try This.

CREATE TABLE `try`.`testing` ( 
`id` INT NOT NULL AUTO_INCREMENT, 
`date` DATE NOT NULL , 
`text_1` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , 
`text_2` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
KEY (`id`) 
) ENGINE = MyISAM;

https://dev.mysql.com/doc/refman/5.6/en/example-auto-increment.html

Vipin Jain
  • 3,686
  • 16
  • 35