1048 Column value cannot be null

I am stuck, I can’t fix this error that I get, and I think it may be that my database settings are messed up.

Here, where the data is placed on the form

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

and here php puts this in the database

     <?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));
?>

(!) Fatal error: throw a "PDOException" exception with the message "SQLSTATE [23000]: integrity violation violation: 1048 The column" actual_quote "cannot be" null "in C: \ wamp \ www \ Quotr \ webweb2.php on line 113 (!) PDOException: SQLSTATE [23000]: integrity violation: 1048 The column "actual_quote" cannot be empty in C: \ wamp \ www \ Quotr \ webweb2.php on line 113 Call Stack Location of the time memory function 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

( 3 , - )

+4
3

. , .

, , "" (null) , . , $_POST['actual_quote'] , null. , null .

: s " name="submit1"s.

+2

$actual_quote null, $_POST ['actual_quote'] ... , NULL. NULL , ( ), $_POST ['actual_quote'] ( ).

$actual_quote = (isset($_POST['actual_quote']) ? $_POST['actual_quote'] : '');
+1

. " " . :

"Integrity constraint violation: 1048 Column 'MoneyMethod' cannot be null".

:

{!! Form::select("MoneyMethod", $MoneymethodInfo, null,["class"=>"form-control MoneyMethod required","id"=>"MoneyMethod"]) !!},

"MoneyMethod" $table->string('MoneyMethod', 100); , ,

$riskfund->Moneymethod  = Input::get('Moneymethod');

, "Moneymethod" . .

, "" , , . .

0

Source: https://habr.com/ru/post/1544207/


All Articles