Field 'id' doesn't have a default value #844

Open
opened 2026-10-05 00:20:20 +02:00 by adam · 2 comments
Owner

I have the following issue when adding a new tag:

Warning: [mysql error 1364] Field 'id' doesn't have a default value

INSERT INTO piwigo_tags
  (name,url_name)
  VALUES('newtag','newtag') in [...]/include/dblayer/functions_mysqli.inc.php on line 845

Piwigo reports that the tag has been successfully added, but it hasn't.

The same issue occurs when searching:

Warning:  [mysql error 1364] Field 'id' doesn't have a default value

INSERT INTO piwigo_search
  (rules, last_seen)
  VALUES
  ('a:1:{s:1:\"q\";s:6:\"foobar\";}', NOW() )
; in [...]/include/dblayer/functions_mysqli.inc.php on line 845

Tested using Piwigo 2.9.4, MariaDB 10.3 and PHP 7.

The simple "echo error" in functions_mysqli.inc.php does also cause a Warning: Cannot modify header information - headers already sent by (output started at [...]/include/dblayer/functions_mysqli.inc.php:844) in [...]/include/page_header.php on line 101.

I have the following issue when adding a new tag: ``` Warning: [mysql error 1364] Field 'id' doesn't have a default value INSERT INTO piwigo_tags (name,url_name) VALUES('newtag','newtag') in [...]/include/dblayer/functions_mysqli.inc.php on line 845 ``` Piwigo reports that the tag has been successfully added, but it hasn't. The same issue occurs when searching: ``` Warning: [mysql error 1364] Field 'id' doesn't have a default value INSERT INTO piwigo_search (rules, last_seen) VALUES ('a:1:{s:1:\"q\";s:6:\"foobar\";}', NOW() ) ; in [...]/include/dblayer/functions_mysqli.inc.php on line 845 ``` Tested using Piwigo 2.9.4, MariaDB 10.3 and PHP 7. The simple "echo error" in `functions_mysqli.inc.php` does also cause a `Warning: Cannot modify header information - headers already sent by (output started at [...]/include/dblayer/functions_mysqli.inc.php:844) in [...]/include/page_header.php on line 101`. <!-- github-sync-id:391379219 -->
Author
Owner

The issue is in the table schema (e.g. for piwigo_search):

+-----------+------------------+------+-----+---------+-------+
| Field     | Type             | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+-------+
| id        | int(10) unsigned | NO   | PRI | NULL    |       |
| last_seen | date             | YES  |     | NULL    |       |
| rules     | text             | YES  |     | NULL    |       |
+-----------+------------------+------+-----+---------+-------+

NULL is not allowed for id, but the default is NULL.
This seems to affect all tables in piwigo_structure-mysql.sql that are just using NOT NULL auto_increment.

The issue is in the table schema (e.g. for `piwigo_search`): ``` +-----------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------------+------+-----+---------+-------+ | id | int(10) unsigned | NO | PRI | NULL | | | last_seen | date | YES | | NULL | | | rules | text | YES | | NULL | | +-----------+------------------+------+-----+---------+-------+ ``` `NULL` is not allowed for `id`, but the default is `NULL`. This seems to affect all tables in [piwigo_structure-mysql.sql](https://github.com/Piwigo/Piwigo/blob/master/install/piwigo_structure-mysql.sql) that are just using `NOT NULL auto_increment`. <!-- github-comment-id:447569754 -->
Author
Owner
[Solved](https://piwigo.org/forum/viewtopic.php?pid=181017#p181017). <!-- github-comment-id:869213914 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#844