# Adding database entry from panel (comments example from the guide)

**URL:** <https://forum.getkirby.com/t/adding-database-entry-from-panel-comments-example-from-the-guide/30378>\
**Category:** Questions\
**Tags:** v4\
**Created:** [January 1, 2024, 2:22pm UTC](https://forum.getkirby.com/t/adding-database-entry-from-panel-comments-example-from-the-guide/30378 "2024-01-01T14:22:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![assbach](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/assbach/32/13832_2.png) [@assbach](https://forum.getkirby.com/u/assbach)\
**Post date:** [January 1, 2024, 2:22pm UTC](https://forum.getkirby.com/t/adding-database-entry-from-panel-comments-example-from-the-guide/30378/1 "2024-01-01T14:22:53Z")

</div>

First of all: **Happy New Year** to everyone!

I’m trying to follow [this tutorial](https://getkirby.com/docs/guide/virtual-pages/content-from-database) and getting it to work, but i fail adding/inserting new entries from the panel.

When i try to add a comment/page after submitting the page creation dialog it directly says “page could not be found”, and when i manually add an entry to the database (via PHPMyAdmin for example) and try to create a page with the same title, there is an error saying “a page with this slug already exists”, so the system does find existing db entries. What am i missing here? Deleting and editing from the panel works fine. I’m sorry, the screenshots are in german.

 ![SCR-20240101-nlfb](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/f/f42628ad771ec7a858d23e2be292d0f1120257bc.png)  
 ![SCR-20240101-nldj](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/d/d9a0043fd95c70b7aecd89415fb6a680fedb72e1.png)

---

<div class="post-metadata">

**Author:** ![assbach](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/assbach/32/13832_2.png) [@assbach](https://forum.getkirby.com/u/assbach)\
**Post date:** [January 4, 2024, 5:50pm UTC](https://forum.getkirby.com/t/adding-database-entry-from-panel-comments-example-from-the-guide/30378/2 "2024-01-04T17:50:26Z")

</div>

I found the solution [here](https://forum.getkirby.com/t/virtual-pages-from-database-question/14908/25) in an old topic. When inserting you have to mention every field, even if empty. Quite confusing and i didn’t find a single hint in the docs.

so change this:

```auto
$data['slug'] = $this->slug();
return Db::insert('comments', $data);

```

to this:

```auto
return Db::insert('comments', [
				'slug' => $this->slug(),
				'text' => '',
				'user' => '',
				'title' => '',
				'status' => ''
]);

```

and it works.

Now i can adapt to my needs.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [January 4, 2024, 5:57pm UTC](https://forum.getkirby.com/t/adding-database-entry-from-panel-comments-example-from-the-guide/30378/3 "2024-01-04T17:57:55Z")

</div>

What does your database table setup look like, the example in the docs should work as intended unless you have set your fields to `Not NULL`. This is the field setup I was using:

 ![Bildschirmfoto 2024-01-04 um 18.56.44](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/5/57d486529eb815f5c863604550d3612932dfdecc.png)

---

<div class="post-metadata">

**Author:** ![assbach](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/assbach/32/13832_2.png) [@assbach](https://forum.getkirby.com/u/assbach)\
**Post date:** [January 4, 2024, 7:18pm UTC](https://forum.getkirby.com/t/adding-database-entry-from-panel-comments-example-from-the-guide/30378/4 "2024-01-04T19:18:04Z")

</div>

Makes sense now that you mention it, but that info is missing in the example. I just quickly tried to build that table with PHPMyAdmin from what i saw in the article and “not null” seems to be the default in PHPMyAdmin (local MAMP). Thing is that i didn’t get any hint or clue from the error-message where to look for mistakes. Debugging is on but didn’t show up.
