News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Bug ? Error: Duplicate entry '60-2' for key 'PRIMARY'

Started by aegersz, October 22, 2018, 08:31:12 AM

Previous topic - Next topic

aegersz


https://forum.site-name.org/index.php?action=admin;area=manageboards;sa=board2
Duplicate entry '60-2' for key 'PRIMARY'

Error: Duplicate entry '60-2' for key 'PRIMARY'
Database Error: Duplicate entry '60-2' for key 'PRIMARY'


INSERT INTO smf209_moderators(`id_board`, `id_member`)
VALUES
(60, 2),
(60, 2)
File: /var/www/html/Sources/Subs-Boards.php
Line: 763

call_user_func                    /index.php:176
                                       
AdminMain   

ManageBoards                   Sources/Admin.php:754
 
EditBoard2                   Sources/ManageBoards.php:111

modifyBoard                   Sources/ManageBoards.php:683
   
SMF_DB_MySQLi->insert   Sources/Subs-Boards.php:763

SMF_DB_MySQLi->query   Sources/Subs-Db-mysql.php:1488

SMF_DB_MySQLi->error   Sources/Subs-Db-mysql.php:1171

log_error                            

Sources/Subs-Db-mysql.php:126
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

aegersz


Ran it manually in phpmyadmin but i wonder why it heppenned ?

INSERT INTO smf209_moderators
(`id_board`, `id_member`)
VALUES
    (60, 2)


SELECT * FROM `smf209_moderators`
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Arantor

Did you try to add the same board moderator twice at the same time?

aegersz

yes, i was updating a board and those fields get autofilled.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

aegersz

does this code look right to you ?

                        $smcFunc['db_insert']('insert',
                                '{db_prefix}moderators',
                                array('id_board' => 'int', 'id_member' => 'int'),
                                $inserts,
                                array('id_board', 'id_member')
                        );

The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Arantor

Yes, but if you try to insert two rows the same, it will fail... which is what the original issue was.

Which implies the $inserts got two values, presumably from you trying to add the same person twice unnecessarily.

aegersz

yes BUT i added it successfully as i did not see any duplicate.

it couldn't've been if i added it manually.

maybe a DB anomaly.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Kindred

really....  I know I've told you this before....   you should never, ever, ever, ever edit the database directly
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Except, as usual we've gone down irrelevant tangents. You adding it manually in the DB is not relevant.

From the UI it appears you tried to add the same user twice as a moderator causing the error originally shown. It is not surprising that if you dint use the UI and don't try to add the same person twice, you don't get an error... what you've basically said is "I have a flat tyre on my car but if I use my bike, it's fine".

aegersz

OK guys, I consider myself told off !

it's only a harmless little DB update, how bad can it be ?

(don't answer that)
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

Advertisement: