Doesn't have a default value errors
Description: Development team script for fixing the error on phpBB3 boards using MySQL.
In Categories: Miscellanea
- Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.1/kb/article/doesnt-have-a-default-value-errors/]Knowledge Base - Doesn't have a default value errors[/url]
When carrying out any one of many actions on your board, you may find your self getting errors such as the one in this example error.
This can happen on any one or multiple database columns in the database so the column mentioned in the error could vary but the problem is very likely the same.Field 'forum_last_post_subject' doesn't have a default value 
This is usually a result of the database being upgraded. For example from MySQL 4.0.x to 4.1.x or 5.x, quite often the web host will do such an upgrade without warning.
The problem is that the schema of the databases in older versions will not work correctly in newer versions without various things being changed. The result of such an upgrade without fixing the database schema is the above mentioned error.
This issue has become more common on the support forums recently, and more importantly many people have been incorrectly submitting this as a phpBB bug. As a result, the Development team decided it would be in their best interests to address the problem. Thus they produced a script which could be executed producing a set of SQL queries to correct the database schema.
- Make complete backups of the board's database before executing any queries this script provides.
- Please make sure that you are running the latest version of phpBB3 before doing anything
- Grab the contents of the this file (for 3.1.x) or this file (for 3.2.x) and use a proper file editor (like Notepad++, but NOT Windows Notepad) and paste the contents in it. Save the file as mysql_upgrader.php
- Use your ftp client to upload the mysql_upgrader.php into the board root. This is the same location as the board's config.php.
- Browse to this file in your web browser via its URI. So using the phpBB.com board as an example, you would browse to
- This will cause the script to scan your database and then provide the correct schema for your MySQL version. As such it will output a list of SQL queries which can
- Be run all in one go via phpmyadmin (see: Executing SQL Queries in phpMyAdmin)
- Or run via the MySQL console
- Or be given to the host to run
One of the above three options MUST be performed to actually repair your database.
- Once the provided queries have been executed, the errors should be fixed and the board working correctly.
- IMPORTANT: Now use your ftp client to remove the file mysql_upgrader.php from your board root.
It should be noted this script is designed to fix columns in the default phpBB3 schema. As such it will not be a cure if this problem occurs with any extension related columns. If you have this issue with an extension related column, you will need to seek support in the extension's download topic in the Extensions in Development forum, the dedicated support area for the extension in the Customisation Database or from the author's author where else you got it from.
- <zerok> Updated script-link for phpBB 3.0.0
- <karlsemple> Updated script download for phpBB 3.0.1
- <karlsemple> Updated script download for phpBB 3.0.2
- <karlsemple> Updated article to include note pertaining to mod columns
- <Noxwizard> Updated script download for phpBB 3.0.3
- <Erik Frèrejean> Updated script download for phpBB 3.0.4
- <ric323> Added in a few missing commas and apostrophes.
- <Paul>Updated script download for phpBB 3.0.5
- <ric323>Added "one of these steps must be performed" notice.
- <stevemaury> Deleted the reference to decompressing an archive. The files are not compressed
- <iWisdom> Added 3.0.6 download
- <Noxwizard> Added 3.0.7 download
- <rxu> Added 3.0.8 download
- <Noxwizard> Added 3.0.9 download
- <Erik Frèrejean> Updated for 3.0.11
- <JimA> Edited to be suitable for all 3.1.x and 3.2.x versions