Cannot Approve Comment, Get “Search Not Found” or “Oops, No comment with this ID” on WordPress

If you get any of the symptoms on the title, and recently just restoring your WordPress database (maybe moving from different hosting company to the other) then this article might be the answer that you are looking for.

Recently, after I moved one of the WordPress blog into different hosting/server manually, I got this strange behavior from WordPress upon trying to approve on of the comment.  When I click “Approve” link, after the usual thing: submit the command, update the link text from “Approve” to “Unapprove” – suddently the background of the comment become red (indicating some error). I cannot change the status.

Upon some googling, a similar problem can be work around by edit the comment and save it. But this workaround doesn’t work on this particular problem. I even get the error message “No comment with this ID”.

The next thing I try is to submit comment manually from one of the post. To my surprise, I have the search not found displayed. (Not page not found) – Is my theme broken? – that’s one of the thing that come to my mind. After make sure that the comment form is submitted to “wp-comments-post.php” and that file is actually exist, then I conclude that it was not the theme.

To make it even stranger, the test comment is actually submitted and now can be seen from the dashboard. This is bad, as the user will see the error without knowing that the comment is actually submitted.

Dig into The Database

[PHPMyAdmin Field Properties]

Step 1 - change the AUTO INCREMENT setting

Then the next item would be checking the database itself. I used the PHPMyAdmin that installed by the provider. I just go browse the “comments” table until I found the particular comment that I was trying to approve. And there lies the problem … The previous comment got ID 214 and this particular comment and my test comment got comment_ID of 0 (zero).

From here I can start see the light. That behavior is caused by the structure/setting of the field of that particular table not set to “AUTO INCREMENT”.

The fix is easy:

  1. Just go to “Structure” tab on that table, click change setting on “comment_ID” and just tick Auto Increment check box.
  2. Try now submitting another comment manually – you should be able to submit without “search not found” error.
  3. Go back to the PHPMyAdmin to make sure the new entry is there with correct ID. In this case got comment_ID of 215.
  4. Then delete the new entry, the test comment.
  5. Edit the particular comment (that you originally want to approve) with the comment ID from the new comment (#215)
  6. Done. You should be able to approve it as normal.
  7. Do step #1 above to all the id field of all the tables on the database list, as the chance is they are all affected. (Remember every table there will be only 1 ID field – usually the one with Unique property or/and named with .”..ID” – but some lookup table could have no ID field – so not all the table in the database have auto-increment-ID)

Why it Happen?

This is to turn out be my own negligence. During exporting the database from previous server, I forget to tick “Add AUTO_INCREMENT value“. So all the table is actually affected. This is why the manual migrating is prone to manual mistake like this. If you use a tool or program to do this and still got this problem then you should feedback it to the creator.

[Export Tab from PHPMyAdmin]

Make sure to add AUTO INCREMENT during exporting

Without the auto increment, since wordpress will not define the value, it will got 0(zero) by default. And 0 (zero) in PHP programming language means “NULL” – the value to indicate nothing or something wrong. That’s why the “Search not found” message was displayed because the comment in question is having no ID. That’s why also I cannot change the status or even delete the comment. As far as PHP/MySQL concern, comment with ID=0 does not exist.

This also explaind, why the new comment, although got error, but it still can be displayed on dashboard.

And another problem solved…

Hope this solves yours to.

Be Sociable, Share!



Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Newsletter Subscription

Get website update right into your mail box! And rest asure we respect your privacy and will never abuse your trust with your email address.
SIGN UP now! It's Free..