Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP MyAdmin Inserting data twice

I am adding afew tables to a current database that will drive an online menu.

So far I have created the 'Menu Categories' table. Below is the table structure.

CREATE TABLE IF NOT EXISTS `menu_categories` (
  `id` int(2) NOT NULL AUTO_INCREMENT,
  `cat_id` varchar(6) NOT NULL,
  `cat_name` text NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `cat_id` (`cat_id`)
)

I have yet to write the PHO scripting but just wanted to insert a few dummy categories for testing, but when I insert a category and then browse the table the data has been entered twice, so i get two of each category.

I have looked around and cannot for the life of me figure out why, is this just PHP MyAdmin?

Below are some print screen of inserting data and the end result:

Inputting the dummy data

Inputting the dummy data

The sql query for inserting dummy data

The sql query for inserting dummy data

Preview of table with duplicate entries

Preview of table with duplicate entries

Any idea what is going on here?

Thanks

*edit: I forgot to add that I tried setting the 'cat_id' to unique. Then when I ran the insert command, I then received an error about inserting duplicate data

like image 391
chinds Avatar asked Mar 31 '15 18:03

chinds


1 Answers

Okay, so I was having the same issue, and I finally realized that I was actually inserting data in the table.

I figured it out like this: when you press insert and you fill out the field and press go, you are going to be taken to another page that has the command line query but notice on the top is showing this message: "One row has been inserted, inserted row id 3" in a light green bar.

The mistake that I was making was: I was clicking the "go" button at the bottom of the query line command, and that was just inserting that query in the table again. so, instead of clicking "go" just click the "Browse" button that is on the top navigation bar that's next to the "structure" button.

like image 50
Mylove Nemese Avatar answered Oct 23 '22 20:10

Mylove Nemese