I start adding an article to the database, and I get an error:

Fatal error: Uncaught [HY000] - SQLSTATE [HY000]: General error: 1364 Field 'add_time' doesn't have a default value trace:
# 0 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (882): RedBeanPHP \ Driver \ RPDO-> runQuery ('INSERT INTO `ne ...', Array)
# 1 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (919): RedBeanPHP \ Driver \ RPDO-> GetAll ('INSERT INTO `ne ...', Array)
# 2 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (3547): RedBeanPHP \ Driver \ RPDO-> GetOne ('INSERT INTO `ne ...', Array)
# 3 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (4976): RedBeanPHP \ Adapter \ DBAdapter-> getCell ('INSERT INTO `ne ...', Array, 0)
# 4 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (5103): RedBeanPHP \ QueryWriter \ AQueryWriter-> insertRecord ('news', Array, Array)
# 5 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (7646): RedBeanPHP \ QueryWriter \ AQueryWriter-> updateRecord ('news', Array, 0)
# 6 D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php (7233): RedBeanPHP \ Repository \ Fluid-> storeBean (Obj in D: \ webserver \ OpenServer \ domains \ muzzone.ua \ function \ rb.php on line 720

Here is the code to connect to the database:

<?php require "rb.php"; R::setup( 'mysql:host=localhost;dbname=muzzonebase', 'root', '' ); session_start(); ?> 

Here is the form

 <form action="function/adding.php" method="POST" id="add"> <p class="zagolovok">Форма добавления статьи</p> <input type="text" name="name" value="" class="registrationinput" placeholder="Введите название статьи"><br> <p class="text">Добавьте картинку для своей статьи</p> <input type="file" name="image" value=""><br> <textarea name="short_text" form="add" rows="100" cols="300" class="registrationinput" id="short_text" maxlength="900" placeholder="Введите короткий текст для стать который будет отображатся на главной странице!"></textarea><br> <textarea name="text" form="add" cols="300" class="registrationinput" id="long_text" placeholder="Сдесь введите текст статьи"></textarea><br> <button type="submit" name="add_news" class="registrationbutton">Добавить статью</button> </form> 

But the form handler

 <?php require "db.php"; $data = $_POST; if(isset($data['add_news'])) { if(trim($data['name'])=='') { $errors[]='Введите название статьи!'; } if(trim($data["short_text"])=='') { $errors[]='Введите короткий текст для статьи!'; } if(trim($data["text"])=='') { $errors[]='Введите текст для статьи!'; } if(!empty($errors)){ foreach($errors as $error){?> <div><?php echo $error;?></div><hr> <?php } }else { $new = R::dispense ('news'); $new->name = $data['name']; $new->shorttext = $data['short_text']; $new->text = $data['text']; $new->img = $data['image']; R::store($new); echo "Вы успешно добавили статью в базу даных"; } } ?> 

The error is displayed when you click on the add button.

    1 answer 1

    Well, so what's not clear? You also wrote in error that the add_time field does not have a default value, which means it is mandatory, add it to your insert or add a default value (for example, CURRENT_TIMESTAMP)

    • Previously, no nada was doing it. - Oleksandr Tatarinov
    • Perhaps the mysql version has been updated, in any case, the description above will help solve this problem - madfan41k