Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: spoileds2601 - marraskuu 18, 2019, 11:07:55 AP

Otsikko: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 18, 2019, 11:07:55 AP
Hello,
I am trying to create a new topic on my forum and I get the following error.

Thanks for the help!
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 18, 2019, 11:46:40 AP
That's from a mod.  Go into your database and set the field value to 'null'.
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 18, 2019, 11:53:26 AP
Thanks for your answer.
Do you know exactly where in the database?
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 18, 2019, 11:56:38 AP
Don't recognize it, but you can run query to find it -



SELECT table_name,table_schema
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name='hidden_reason'



Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 19, 2019, 10:48:13 AP
I have done what you told me and the error was shown in the table:    smf_messages

But now the following error appears:
¡Un error ha ocurrido!
The database value you're trying to insert does not exist: id_board



The following is the PHP code where the error came from before

// 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','hidden_reason' => 'null',
),
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')
);
$msgOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg');
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 19, 2019, 05:52:45 IP
Do you see id_board in smf_messages?
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 19, 2019, 06:35:00 IP
Yes, look at it
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 19, 2019, 07:24:23 IP
I think you have a mod problem.  Which mods are you running?
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 19, 2019, 08:03:28 IP
No one
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Arantor - marraskuu 20, 2019, 03:16:32 AP
Replace the code you posted with:


// 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')
);
$msgOptions['id'] = $smcFunc['db_insert_id']('{db_prefix}messages', 'id_msg');
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 20, 2019, 11:23:38 AP
If I put the code you mention, I get the error again.
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Illori - marraskuu 20, 2019, 11:40:24 AP
after you found the column did you go to structure tab and set the default as null for that column?
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 20, 2019, 11:42:58 AP
hidden_reason is not a core field, you have remnant code from a broken mod.  If you can't fix it, upload clean set of files.

https://wiki.simplemachines.org/smf/How_to_upload_a_fresh_set_of_files
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Illori - marraskuu 20, 2019, 11:46:14 AP
Lainaus käyttäjältä: Sir Osis of Liver - marraskuu 20, 2019, 11:42:58 AP
hidden_reason is not a core field, you have remnant code from a broken mod.  If you can't fix it, upload clean set of files.

https://wiki.simplemachines.org/smf/How_to_upload_a_fresh_set_of_files


clean files will not remove the column from the database where the issue is happening.
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 20, 2019, 11:48:56 AP
No, but it won't be called by code, so it would be ignored, wouldn't it?  He already tried assigning "null" value to the field.

Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Illori - marraskuu 20, 2019, 11:53:45 AP
Lainaus käyttäjältä: Sir Osis of Liver - marraskuu 20, 2019, 11:48:56 AP
No, but it won't be called by code, so it would be ignored, wouldn't it?  He already tried assigning "null" value to the field.



no it is not ignored, that is the issue. the field has to have something filled in by default.
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 20, 2019, 11:56:08 AP
He already did that, and got a different error (read above).
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Illori - marraskuu 20, 2019, 11:59:07 AP
I don't see where above it says the value was changed, just that it was located in the database.

the errors listed seem to be the same from what I can see.
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Sir Osis of Liver - marraskuu 20, 2019, 12:01:24 IP
Lainaus käyttäjältä: spoileds2601 - marraskuu 19, 2019, 10:48:13 AP
I have done what you told me and the error was shown in the table:    smf_messages

But now the following error appears:
¡Un error ha ocurrido!
The database value you're trying to insert does not exist: id_board


It may have been done incorrectly, but apparently he did try it.
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: Arantor - marraskuu 20, 2019, 12:11:28 IP
The issue I put code for is because there were a number of columns, and a number of values for those columns but there were more columns listed than there were values...
Otsikko: Re: Database Error: Field 'hidden_reason' doesn't have a default value
Kirjoitti: spoileds2601 - marraskuu 20, 2019, 02:50:36 IP
It is already resolved, thank you