1048列值不能为空

use*_*183 5 php database forms

我被困住了,无法解决这个错误,我认为这可能是我的数据库选项搞砸了

这是数据放入表格的地方

 <form name = "quoted" method="post" onsubmit="get_action(this);">
 <input id = "poster" type="text" name="poster" required="required" placeholder = "Credited Individual.">     <br>
 <textarea class = "actual_quote" name = "actual_quote" required="required" placeholder = "Write the question here!"></textarea><br><br><br>
 <div class = "checkboxes" required="required">
     <h3 style = "margin-top:-20px;">Please select one catagory that the quote falls into.</h3>
     <label for="x"><input type="radio" name="x" value="Inspirational" id = "inspirational.php" checked="checked" />    <span>Inspirational</span></label><br>
     <label for="x"><input type="radio" name="x" value="Funny" id = "funny.php" /> <span>Funny</span>    </label><br>
     <label for="x"><input type="radio" name="x" value="OutofContext" id = "outofcontext.php"/>    <span>OutofContext</span></label>
 </div>
 <input id = "submit1" name="submit1"s type="submit"><br>
 </form>
Run Code Online (Sandbox Code Playgroud)

这是将其放入数据库的php

     <?php
     $db_name = 'submissions';
     $db_user = 'root';
     $db_pass = '';
     $db_host = 'localhost';
     try {
     $db = new PDO('mysql:host = localhost;dbname=submissions', $db_user, $db_pass);
     $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
     }
     $actual_quote = (isset($_POST['actual_quote']) ? $_POST['actual_quote'] : null);
     $poster = (isset($_POST['poster']) ? $_POST['poster'] : null);
     $sql = "INSERT INTO data (actual_quote, poster) VALUES ( :actual_quote, :poster)";
     $query = $db->prepare($sql);
     $query->execute(array(':actual_quote'=>$actual_quote, ':poster'=>$poster));
?>
Run Code Online (Sandbox Code Playgroud)

(!)致命错误:消息'SQLSTATE [23000]未捕获的异常'PDOException':违反完整性约束:1048第113行的C:\ wamp \ www \ Quotr \ webweb2.php中的列'actual_quote'不能为空'(! )PDOException:SQLSTATE [23000]:违反完整性约束:1048行113上的C:\ wamp \ www \ Quotr \ webweb2.php中的列'actual_quote'不能为null调用堆栈时间内存函数位置1 0.0015 257160 {main}() .. \ webweb2.php:0 2 0.0206 267672 execute().. \ webweb2.php:113

当我确实单击数据库中的null并单击表单上的提交按钮时,错误消失并且数据显示在数据库中,但是没有值,那里什么也没有

有人可以告诉我怎么了,以及如何解决这个问题。如果在代码中,我个人认为数据库有问题,下面是一些图片。

http://i.imgur.com/0wrd7bT.png

http://i.imgur.com/OKEWCmf.png

(忽略最后一张照片的前三个,最后一个是我所在的位置)

Loc*_*cke 4

数据库没有任何问题。它正在做它应该做的事情。

当数据库向您提供这些错误时,它告诉您您正在尝试将“无”(空)输入到不允许的列中。您没有发送任何内容,因为如果$_POST['actual_quote']未设置,则为空。如果未设置,则删除该操作,或者允许数据库中为空。

另外:去掉ins后的。"name="submit1"s