Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: valis1952 on April 06, 2022, 10:31:22 PM

Title: Database Error: Field 'ua_os' doesn't have a default value
Post by: valis1952 on April 06, 2022, 10:31:22 PM
After upgrade to 2.1.1 from 2.0.19 I get this when attempting to post new

QuoteField 'ua_os' doesn't have a default value
File: /var/www/vhosts/xxxx.net/yyyy.net/forum/Sources/Subs-Post.php
Line: 1896

I check Subs-Post.php line 1896:

Quote1891 // Insert the post.
1892   $msgOptions['id'] = $smcFunc['db_insert']('',
1893      '{db_prefix}messages',
1894      $message_columns,
1895      $message_parameters,
1896      array('id_msg'),
1897      1
1898   );

Any clues? thx
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Sir Osis of Liver on April 06, 2022, 10:59:29 PM
Have you installed any mods?
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Kindred on April 07, 2022, 12:55:14 AM
So, give the field a default of NULL by using phpmyadmin in the sql
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Arantor on April 07, 2022, 03:14:52 AM
Quote from: Sir Osis of Liver on April 06, 2022, 10:59:29 PMHave you installed any mods?


This is from the old "log user agent and operating system on posts" mod.
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Doug Heffernan on April 07, 2022, 06:46:53 AM
Quote from: Arantor on April 07, 2022, 03:14:52 AM
Quote from: Sir Osis of Liver on April 06, 2022, 10:59:29 PMHave you installed any mods?


This is from the old "log user agent and operating system on posts" mod.

Indeed. I have seen posts about this error quite a few times here.

@valis1952, if you are still using this mod, doing what @Kindred posted above should fix the error. However, if you are not using it anymore, the best course of action imo would be to delete/remove all its fields from the database.
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Dzonny on April 07, 2022, 07:09:21 AM
I had a few similar messages after I upgraded to 2.1, just give default null in phpMyAdmin and that should do the trick. ;)
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: valis1952 on April 07, 2022, 10:19:42 AM
Thanks everyone... Mr Newbie here... I can get to phpMyAdmin, and find the file...

But what do I actually do then?

Thx
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Kindred on April 07, 2022, 10:21:47 AM
https://popsql.com/learn-sql/mysql/how-to-add-a-default-value-to-a-column-in-mysql
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Doug Heffernan on April 07, 2022, 10:29:59 AM
Quote from: valis1952 on April 07, 2022, 10:19:42 AMThanks everyone... Mr Newbie here... I can get to phpMyAdmin, and find the file...

It is not a file, but a column/field in the smf_messages table.

Quote from: valis1952 on April 07, 2022, 10:19:42 AMBut what do I actually do then?

Are you still using that mod? If yes, at the smf_messages, go the structure, select the ua_os filed and click the edit button. Next step would be to untick NOT NULL and save the changes. This will allow said field to have a null default value and it will make the error go away.

However, if you are not using the mod anymore, which has added that field, the best course of action imo would be to delete/remove said field altogether from the database. There is no point in cluttering your database with fields/tables left behind from old unused mods.

Hope it helps.
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: valis1952 on April 09, 2022, 10:35:46 PM
Okay. Thanks to everyone who replied. Mission accomplished!
Title: Re: Database Error: Field 'ua_os' doesn't have a default value
Post by: Doug Heffernan on April 10, 2022, 08:50:58 AM
Glad to hear that it got solved.