Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'post' cannot be null

Tags:

sql

php

mysql

I have this codes but when I try these code I am getting:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'post' cannot be null this error.

I could not find any solution. I tried another functions which are work they are worked but this one is not work.

?>
<form method="post">
Buraya yaz <br><textarea style="resize:none" name="post"></textarea> <br><input type="submit" value="Gönder">
</form>

<?php 
if(empty($_POST['post'])){
echo 'you should fill the area.';
exit;
}
if (empty($errors) === true) {
$users->sendpost($post);
}
?>

public function sendpost($post){
$query  = $this->db->prepare("INSERT INTO `posts` (`post`) VALUES (?) ");
$query->bindValue(1, $post);
try{
$query->execute();
}catch(PDOException $e){
die($e->getMessage());
}   
}
like image 682
Baran Sengul Avatar asked Aug 29 '26 23:08

Baran Sengul


1 Answers

insert $post = $_POST['post'];

$post = $_POST['post'];

if(empty($_POST['post'])){
echo $errors[] = 'you should fill the area.';
}
if (empty($errors) === true){
$users->sendpost($post);
}
like image 181
liam.derossi Avatar answered Aug 31 '26 15:08

liam.derossi