我有此代码,但是当我尝试这些代码时,我得到:
SQLSTATE [23000]:违反完整性约束:1048列“ post”不能为null,此错误。
我找不到任何解决方案。我尝试了另一种可以正常工作的功能,但这个功能不起作用。
?>
<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);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句