我想通过注解框插入大文本如何在php中实现这一点?

myss37ts  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(328)

我试图在表单的评论框中提交一条很长的消息(比如2000多封信)。但得到“评论还没有提交”。请检查以下代码:
我已经将数据库中的注解类型改为文本、mediumtext和longtext,但没有任何效果。它仍然显示“评论尚未提交”。

<?php
    if(isset($_POST['submit']))
    {
        $cs_name = $_POST['name'];
        $cs_email = $_POST['email'];
        $cs_comment = $_POST['comment'];
        $cs_image = implode(',', $_FILES['image']['name']);
        $cs_images = $_FILES['image']['name'];
        $cs_image_tmp =  $_FILES['image']['tmp_name'];
        $cs_image_type = $_FILES['image']['type'];
        $cs_rating = $_POST['rating'];
        $cs_date = time();
        if(empty($cs_name) or empty($cs_email) or empty($cs_comment))
        {
            $error_msg = "All (*) feilds are compulsary";
        }  
        else
        {
            $cs_query = "INSERT INTO `comments` (`id`, `date`, `name`, 
            `username`, `comp_id`, `email`, `image`, `comment`, 
            `rating`,`status`, `type`) VALUES (NULL, '$cs_date', '$cs_name', 
            'user', '$comp_id', '$cs_email', 
            '$cs_image', '$cs_comment', '$cs_rating', 'pending', 'C')";
            if(mysqli_query($con, $cs_query))
            {
                $msg = "Comment Submitted and waiting for Approval";
                for($i=0; $i<=count($cs_image_tmp)-1;$i++)
                {
                    move_uploaded_file($cs_image_tmp[$i], 
                        "admin/images/uploded/$cs_images[$i]");
                }
                header('Location: companies.php?comp_id='.$comp_id.'');
                exit();
            }
            else
            {
                $error_msg = "Comment has not be submitted";
            }
        }
    }
?>

它应该提交一个很长的评论(比如说成功提交了2000多封信),并将其存储在数据库中。

fjnneemd

fjnneemd1#

是的,我得到了答案。我在移动上传文件的for循环之前添加了if条件。这就产生了问题。

if(!empty($cs_images)){
        for($i=0; $i<=count($cs_image_tmp)-1;$i++){
        move_uploaded_file($cs_image_tmp[$i], "admin/images/uploded/$cs_images[$i]");
            }
        }

谢谢你们的评论。

相关问题