Php CodeIgniter致命错误:已耗尽允许的字节内存大小

Php CodeIgniter致命错误:已耗尽允许的字节内存大小,php,codeigniter,fatal-error,php-ini,Php,Codeigniter,Fatal Error,Php Ini,我在我的codeIgniter中得到了这个致命的错误消息,我已经尝试了一些有相同问题的答案 我已经设置了php.ini max_execution_time = 300 max_input_time = 600 memory_limit = 128M 我的主要功能是在博客中添加新的评论,它可以工作,但它会插入重复的数据,我无法摆脱致命的错误消息 addBlogComment函数 function addBlogComment(){ $data=array( 'b

我在我的codeIgniter中得到了这个致命的错误消息,我已经尝试了一些有相同问题的答案

我已经设置了php.ini

max_execution_time = 300 max_input_time = 600 memory_limit = 128M

我的主要功能是在博客中添加新的评论,它可以工作,但它会插入重复的数据,我无法摆脱致命的错误消息

addBlogComment函数

function addBlogComment(){ $data=array( 'blog_id'=> $this->input->post('blog_id'), 'name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'message' => $this->input->post('message'), 'created' => date('Y-m-d H:i:s') ); $this->db->insert('comment',$data); } 函数addBlogComment(){ $data=数组( 'blog_id'=>this->input->post('blog_id'), 'name'=>this->input->post('name'), 'email'=>this->input->post('email'), 'message'=>this->input->post('message'), '创建'=>日期('Y-m-d H:i:s') ); $this->db->insert('comment',$data); }
尝试这样构造控制器:

public function blog( $blog_name = '', $action = '' ){

    $this->load->model("blog_model");

    // What if there is no blog name in the url
    if ( empty( $blog_name ) ) {

        // Load the list of blogs
        $data["result"] = $this->blog_model->getBlogs();
        $this->load->view("view_blog", $data);

    } else {

        // If the blog name in url exists and there is no action display the blog
        if ( !empty( $blog_name ) && empty( $action ) ) {

            $blog_name = $this->getLastUrl();
            $data["result"] = $this->blog_model->getBlogDetails( $blog_name );
            $data["comment"] = $this->blog_model->getBlogComments( $blog_name );
            $this->load->view("view_blog_details", $data);

        }
        // else If there is the action "reply" check if there is some post
        else if ( $action == 'reply' && $this->input->post( 'Comment' ) ) {

            $this->load->library( 'form_validation' );
            $this->form_validation->set_rules( 'name', 'Name', 'trim|required|min_length[4]|xss_clean' );
            $this->form_validation->set_rules( 'message', 'Comment', 'trim|required|min_length[4]|xss_clean' );
            $this->form_validation->set_rules( 'email', 'Email Address', 'trim|required|valid_email' );

            if($this->form_validation->run() == FALSE) {

                redirect( site_url( $blog_name ) );

            } else {

                $msg = 'Message sent.';
                $this->blog_model->addBlogComment();

                // Redirect to prevent F5 submitting duplicate data
                redirect( site_url( $blog_name ) );
            }
        }
    }
}

我刚刚在代码中发现了错误的循环。环路将没有出口,它将再次返回

if($this->form_validation->run() == FALSE)
{
      $this->blog();
}
else
{
      $msg = 'Message sent.';
      $this->blog_model->addBlogComment();
      $this->blog();
}

它将始终返回一个假值,因此它将执行并执行循环结束。

如何共享
addblogcoment()
函数代码,因为问题似乎源自那里?错误指向代码的哪一行?我不认为它来自addBlogComment,因为即使它没有通过验证,我也总是收到致命的错误消息。但不管怎样,我都会添加它。只有当uri类似于:
foo/bar/reply
时才会发生这种情况吗?最后一段是“回复”的地方?另外,这并不相关,但您可能正在使用codeigniters uri库,我认为这是因为您调用了
$this->blog()
是同一个函数,所以它似乎陷入了一个无限循环,一次又一次地调用自己。你想通过
$this->blog()实现什么
if($this->form_validation->run() == FALSE)
{
      $this->blog();
}
else
{
      $msg = 'Message sent.';
      $this->blog_model->addBlogComment();
      $this->blog();
}