News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Database Error

Started by Sassafras, January 21, 2017, 01:38:03 PM

Previous topic - Next topic

Sassafras

Hey, everyone, I'm relatively new to SMF. Recently, the administrator of a small and tight-knit little writers forum that I've been a part of for a few years decided to retire and pass the administrator torch to someone else: that person being me. Anyways, things were going pretty smoothly for about a month, until last night when everything seemed to break for reasons I don't really know. The forums are still viewable and otherwise working fine, but if I try to post a reply to a thread, or a new topic, or anything like that, I get this error-

QuoteDatabase Error
Duplicate entry '15073' for key 'PRIMARY'
File
Line: 1817

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.13, while your database is at version 2.0.4. The above error might possibly go away if you execute the latest version of upgrade.php.

I went searching through CPanel for the correct line it mentioned and managed to find it though I haven't touched it yet just because I didn't want to break it further on accident. Here's the table-

   
Quote$countChange = $msgOptions['approved'] ? 'num_replies = num_replies + 1' : 'unapproved_posts = unapproved_posts + 1';

      // Update the number of replies and the lock/sticky status.
      $smcFunc['db_query']('', '
         UPDATE {db_prefix}topics
         SET
            ' . ($msgOptions['approved'] ? 'id_member_updated = {int:poster_id}, id_last_msg = {int:id_msg},' : '') . '
            ' . $countChange . ($topicOptions['lock_mode'] === null ? '' : ',
            locked = {int:locked}') . ($topicOptions['sticky_mode'] === null ? '' : ',
            is_sticky = {int:is_sticky}') . '
         WHERE id_topic = {int:id_topic}',
         array(
            'poster_id' => $posterOptions['id'],
            'id_msg' => $msgOptions['id'],
            'locked' => $topicOptions['lock_mode'],
            'is_sticky' => $topicOptions['sticky_mode'],
            'id_topic' => $topicOptions['id'],

I have no idea what's really wrong with it or what needs to be changed in order to allow me and my other users to post again, or if it's not even a problem with that and just the possible upgrade that I'm needing for the database. I'm still new to both SMF and CPanel, so any and all help and direction would be very appreciated. Thanks.

Bob Perry of Web Presence Consulting

I guess the first question that comes to mind after reading this is you need to specify more detail or take a snapshot of the error message itself and also verify whether you have cited the correct lines of code that are indicating the problem... it is not a typical method, using cpanel to explore the source files, it is not wrong, it is just not typical for the one in control of the hosting to use the cpanel, most of us use an FTP program for uploading/downloading and a PC based text editor to explore the sources, such as notepad++...

Best Regards,
Bob Perry



"The world is moving so fast these days that the man who says it can't be done is generally interrupted by someone doing it." Elbert Hubbard

Dzonny

Hey there and welcome to SMF.

We'd need more info to help you with this, which SMF version are you using, any mods installed, URL to your forum? Which exact file was indicated in the error?

Sassafras

QuoteHey there and welcome to SMF.

We'd need more info to help you with this, which SMF version are you using, any mods installed, URL to your forum? Which exact file was indicated in the error?

Thanks for the welcome, and apologies. Didn't even think to include all of that.

The version is the latest I belief- 2.0.13
As I just inherited the forum, I'm not totally sure if there are any mods, but I don't believe there are.
Here's the url- hxxp:redwallsurvivor.com/forums/index.php [nonactive]

And here's a screenshot of the error in question, which happens whenever one of my users or I tries to reply to a thread or make a new topic.


I found the file and line it was specifying in CPanel, but didn't know what was wrong with it. I quoted the code for it above.

Please tell me if there's anything else you need to know.

Sir Osis of Liver

Things don't usually break for no reason.  Did you change/edit/install anything?  The error is happening here -



// Insert the post.
$smcFunc['db_insert']('',
'{db_prefix}messages',
array(
'id_board' => 'int', 'id_topic' => 'int', 'id_member' => 'int', 'subject' => 'string-255', 'body' => (!empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] > 65534 ? 'string-' . $modSettings['max_messageLength'] : 'string-65534'),
'poster_name' => 'string-255', 'poster_email' => 'string-255', 'poster_time' => 'int', 'poster_ip' => 'string-255',
'smileys_enabled' => 'int', 'modified_name' => 'string', 'icon' => 'string-16', 'approved' => 'int',
),
array(
$topicOptions['board'], $topicOptions['id'], $posterOptions['id'], $msgOptions['subject'], $msgOptions['body'],
$posterOptions['name'], $posterOptions['email'], time(), $posterOptions['ip'],
$msgOptions['smileys_enabled'] ? 1 : 0, '', $msgOptions['icon'], $msgOptions['approved'],
),
array('id_msg')
);



Have you tried repairing the table with phpmyadmin?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sassafras

QuoteHave you tried repairing the table with phpmyadmin?

No, not yet. I wouldn't know where to start.

Sir Osis of Liver

phpmyadmin is in the MySQL database section of your host control panel.  Load it, find your database in left panel, click on it and a list of tables will be displayed.  Click on smf_messages (assuming you're using default smf_ prefix).  Select checkbox for that table in right panel, then use 'With selected:' dropmenu at bottom to 'Repair table'.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sassafras

Quotephpmyadmin is in the MySQL database section of your host control panel.  Load it, find your database in left panel, click on it and a list of tables will be displayed.  Click on smf_messages (assuming you're using default smf_ prefix).  Select checkbox for that table in right panel, then use 'With selected:' dropmenu at bottom to 'Repair table'.

Thanks so much, this fixed it right up. Me and my other users are all able to post now. Thanks :)

Advertisement: