Knowledge Base

Doesn't have a default value errors
Article ID: 116
Written By: karlsemple
Written On: Mon Nov 17, 2008 3:52 am
Description: Development team script for fixing the error on phpBB3 boards using MySQL.
Link to this article: Select All
[url=http://www.phpbb.com/kb/article/doesnt-have-a-default-value-errors/]Knowledge Base - Doesn't have a default value errors[/url]

Problem
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.
Field 'forum_last_post_subject' doesn't have a default value [1364]
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.

Cause
This is usually a result of the database being upgraded. For example from MySQL 3.0.x or 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.

The Fix
  • Make complete backups of the boards database before executing any queries this script provides.
  • Please make sure that you are running the latest version of phpBB3 and then download
  • Extract the compressed archive to your desktop.
  • Open the file in a plain text editor and read the instructions at the top of the extracted file and act accordingly.
  • Use your ftp client to upload the mysql_upgrader.php into the board root. This is the same location as the boards 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
    Code: Select all
    http://www.phpbb.com/community/mysql_upgrader.php
  • This will cause the script to scan your database and then provide the correct schema for you MySQL version. As such it will output a list of SQL queries which can
    • Be run all in one go via phpmyadmin
    • Or run via the MySQL console
    • Or given to the host to run.
  • Once the provided queries have been executed the errors should be fixed and the board working correctly.
  • Now use your ftp client to remove the files mysql_upgrader.php from your board root.

Note*
  • 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 modification related columns. If you have this issue with a modification related column you will need to seek support in the modifications download topic or from the modifications author.

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