gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 03:03:09 25 4
gpt4 key购买 nike

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

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

最佳答案

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

$post = $_POST['post'];

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

关于php - SQLSTATE[23000] : Integrity constraint violation: 1048 Column 'post' cannot be null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20058252/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com