MyBB Community Forums

Full Version: MYBB SQL Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

after immigrating my server to new IP, all thing are OK, but users can not post reply or thread.
when they post reply it try to post it but nothing happen. when user post new thread the below error appear:
MyBB has experienced an internal SQL error and cannot continue.


[b]If you're a visitor of this website[/b], please wait a few minutes and try again. If this problem persists, please [[email protected]]contact the site owner[/email]. 
[b]If you are the site owner[/b], please check the [url=https://docs.mybb.com]MyBB Documentation[/url] for help resolving [url=https://docs.mybb.com/1.8/faq/]common issues[/url], or get technical help on the [url=https://community.mybb.com/]MyBB Community Forums[/url].



I checked error log and found it:
<error>
 <dateline>1615988414</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1364 - Field 'editreason' doesn't have a default value
Query: 
INSERT
INTO mybb_posts (`tid`,`fid`,`subject`,`icon`,`uid`,`username`,`dateline`,`message`,`ipaddress`,`includesig`,`smilieoff`,`visible`)
VALUES (56213,'30','test',0,'1','Administrator',1615988414,'test',X'1f39385e',0,0,1)
</message>
<back_trace>#0  errorHandler->error() called at [/inc/db_mysqli.php:597]
#1  DB_MySQLi->error() called at [/inc/db_mysqli.php:337]
#2  DB_MySQLi->query() called at [/inc/db_mysqli.php:370]
#3  DB_MySQLi->write_query() called at [/inc/db_mysqli.php:831]
#4  DB_MySQLi->insert_query() called at [/inc/datahandlers/post.php:1548]
#5  PostDataHandler->insert_thread() called at [/newthread.php:414]
</back_trace>
</error>

could you please help me?
Your new hosting uses MySQL in strict mode.
Disable it or (much better imho) alter the field editreason in the mybb_posts to add a default value or allow the null
Strange though because that's a default column so would have expected more people having the issue.
It definitely should have a default value.

When installing:

editreason varchar(150) NOT NULL default '',

When upgrading:

$db->add_column("posts", "editreason", "varchar(150) NOT NULL default '' AFTER edittime");

So not sure why yours wouldn't have it.

Try running this query:

ALTER TABLE `mybb_posts` CHANGE `editreason` `editreason` VARCHAR(150) NOT NULL  DEFAULT '';