Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Grynio on March 19, 2021, 06:17:58 AM

Title: Unable to add new post - database problem
Post by: Grynio on March 19, 2021, 06:17:58 AM
Hi, I need help fixing the forum - it is currently not possible to add new messages due to an error message.

Everything worked fine until I had to change php to 7.4 on the server.
I had the forum updated to 2.0.18.

Then I got a bug in viewing some posts as admin:
[] operator not supported for strings administrator
although other (common) users had no problem displaying these posts correctly.

I found information that such an error may be caused by an old version of the database.
So I converted the database from MariaDB 10.1 to 10.5.

The posts were available for viewing again, but an error appeared when I tried to add a message:
Field 'karma_bad' doesn't have a default value
File: /home/grynko/ftp/forum/Sources/Subs-Post.php     <-- I attached the file to this post
Line: 1839

Note: It looks like your database needs updating. The forum files are currently at SMF 2.0.18 while the database is at 2.0.11. You should run the latest version of upgrade.php.


I used to have the karma log and karma actions mods installed, but they stopped working, so I uninstalled them (probably 4 years ago).

There is info about the upgrade in the error message, but when I try to do it again, I get the following message:
Database Changes
Executing database changes
Please be patient - this may take some time on large forums. The time elapsed increments from the server to show progress is being made!
Executing: "Changing column names." (1 of 43)

!!Error!
Unknown Error!


I did all the repairs and maintenance from the forum panel.

If you have ideas about what to do with it and how to fix it, I'll appreciate any help! :)
Title: Re: Unable to add new post - database problem
Post by: Aleksi "Lex" Kilpinen on March 19, 2021, 08:06:57 AM
The "Field 'karma_bad' doesn't have a default value" error is simple really, you just need to assign that field a default value in the database, usually if there is not one set already, NULL will do.
Title: Re: Unable to add new post - database problem
Post by: Grynio on March 19, 2021, 09:08:23 AM
Quote from: Aleksi "Lex" Kilpinen on March 19, 2021, 08:06:57 AM
is simple really, you just need to assign that field a default value in the database, usually if there is not one set already, NULL will do.

But how noob can do this?
Title: Re: Unable to add new post - database problem
Post by: Aleksi "Lex" Kilpinen on March 19, 2021, 11:46:32 AM
Something like this should work
ALTER TABLE tablename ALTER columnname SET DEFAULT NULL;
Title: Re: Unable to add new post - database problem
Post by: Sir Osis of Liver on March 19, 2021, 01:30:01 PM
Or just use phpmyadmin to edit the column structure.
Title: Re: Unable to add new post - database problem
Post by: Grynio on March 20, 2021, 08:13:03 PM
Thank you for answers, but I really need noob step by step instructions  :-[
Title: Re: Unable to add new post - database problem
Post by: Aleksi "Lex" Kilpinen on March 21, 2021, 02:46:28 AM
Do you have access to your database with a tool like PHPMyAdmin?
Title: Re: Unable to add new post - database problem
Post by: Grynio on March 21, 2021, 03:50:30 PM
Quote from: Aleksi "Lex" Kilpinen on March 21, 2021, 02:46:28 AM
Do you have access to your database with a tool like PHPMyAdmin?

I know how to do it by web app (attached).


EDIT: When I deleted both karma_ problem is solved!
Thanks for help :)