Page 1 of 1

Adding product?

Posted: Wed Mar 31, 2021 7:17 pm
by Dnj1964
Was adding products and everything was working perfect.

Now when product is added, completes the addition with no errors but new product doesn't show in the product list

Checking in the database shows 0 for product id rather than the sequential product number.

1.0.8.0

Re: Adding product?

Posted: Wed Mar 31, 2021 7:36 pm
by Dnj1964
Not sure what the issue actually was.

Stupid mans fix!

Go into products and change the product id to next sequential number.
Go into products_to_categories and make same number change

We'll see when I add another product.

Re: Adding product?

Posted: Wed Mar 31, 2021 8:27 pm
by raiwa
Check that in the database products table the products id has auto increment set.
I’m also wondering how you got this screwed up. Do you have a dB backup from a point where your settings were correct. It might be easier to restore even you have to enter some products again.

Re: Adding product?

Posted: Fri Apr 02, 2021 7:04 pm
by Dnj1964
Still won't auto increment

SQL query:
ALTER TABLE `products`
MODIFY `products_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=334

MySQL said: Documentation
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

Re: Adding product?

Posted: Fri Apr 02, 2021 7:18 pm
by raiwa
Then check if you have another column set to auto increment and remove it.
Or recover a backup, if you have, from a point where the settings where ok.
I wonder how you got these settings wrong.

Re: Adding product?

Posted: Fri Apr 02, 2021 8:33 pm
by ecartz
Also make sure that the products_id column is defined as the primary key for the products table.

Re: Adding product?

Posted: Sat Apr 03, 2021 12:13 am
by Dnj1964
product_id is Primary and only key set on products table.

Refuses to auto_increment.
db-1.jpg
db-2.jpg
db-3.jpg

Re: Adding product?

Posted: Sat Apr 03, 2021 2:31 am
by ecartz
Dnj1964 wrote: ↑Sat Apr 03, 2021 12:13 am product_id is Primary and only key set on products table.

Refuses to auto_increment.
OK. Try the ALTER statement again. It's certainly not going to auto-increment until you set it to auto-increment.

And note, what you need to check is not that it is the only key but that it is the only auto-increment column.

Re: Adding product?

Posted: Sat Apr 03, 2021 3:49 am
by ecartz

Code: Select all

ALTER TABLE `products`
MODIFY `products_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=334
Here's the problem. The PRIMARY is not in that statement. So when you run it, it tries to remove the primary key and then it can't be used as an auto_increment. Try

Code: Select all

ALTER TABLE `products`
MODIFY `products_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, AUTO_INCREMENT=334
That should retain the status as a key and add the auto_increment property.

Re: Adding product?

Posted: Wed Apr 07, 2021 6:09 pm
by Dnj1964
ecartz wrote: ↑Sat Apr 03, 2021 3:49 am

Code: Select all

ALTER TABLE `products`
MODIFY `products_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=334
Here's the problem. The PRIMARY is not in that statement. So when you run it, it tries to remove the primary key and then it can't be used as an auto_increment. Try

Code: Select all

ALTER TABLE `products`
MODIFY `products_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, AUTO_INCREMENT=334
That should retain the status as a key and add the auto_increment property.
@ecartz Thanks ever so much, that worked perfectly