sqlSTATE[23000]: Integrity constraint violation: 1048 Column ‘post’ cannot be null
this error.
我找不到任何解决方案.我尝试了另外的功能,这些功能是他们工作的但是这个功能不起作用.
?>
<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());
}
}
解决方法:
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);
}