News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Database Error: Field 'hidden_reason' doesn't have a default value

Started by spoileds2601, November 18, 2019, 11:07:55 AM

Previous topic - Next topic

spoileds2601

Hello,
I am trying to create a new topic on my forum and I get the following error.

Thanks for the help!

Sir Osis of Liver

That's from a mod.  Go into your database and set the field value to 'null'.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

spoileds2601

Thanks for your answer.
Do you know exactly where in the database?

Sir Osis of Liver

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'



Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

spoileds2601

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');

Sir Osis of Liver

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters


Sir Osis of Liver

I think you have a mod problem.  Which mods are you running?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters


Arantor

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');

spoileds2601


Illori

after you found the column did you go to structure tab and set the default as null for that column?

Sir Osis of Liver

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
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

Quote from: Sir Osis of Liver on November 20, 2019, 11:42:58 AM
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.

Sir Osis of Liver

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.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

Quote from: Sir Osis of Liver on November 20, 2019, 11:48:56 AM
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.

Sir Osis of Liver

He already did that, and got a different error (read above).
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

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.

Sir Osis of Liver

Quote from: spoileds2601 on November 19, 2019, 10:48:13 AM
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.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

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...

Advertisement: