SQLSTATE[23000]:违反完整性约束:1048 列“post”不能为空

2023-12-01

我有这个代码,但是当我尝试这些代码时,我得到:

SQLSTATE[23000]:违反完整性约束:1048 列“post”不能为空 这个错误。

我找不到任何解决方案。我尝试了另一种功能,它们可以工作,但这个功能不起作用。

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

插入 $post = $_POST['post'];

$post = $_POST['post'];

if(empty($_POST['post'])){
echo $errors[] = 'you should fill the area.';
}
if (empty($errors) === true){
$users->sendpost($post);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SQLSTATE[23000]:违反完整性约束:1048 列“post”不能为空 的相关文章

随机推荐