CodeIgniter致命错误:允许的字节大小耗尽

时间:2013-02-06 09:55:54

标签: php codeigniter fatal-error php-ini

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

我已经设置了php.ini


    max_execution_time = 300
    max_input_time = 600
    memory_limit = 128M

但是我仍然收到相同的致命错误消息,我不知道问题是在我的代码中还是在php设置中。

以下是控制器中的一些代码:

public function blog(){
    $this->load->model("blog_model");
    $data["title"] = "CodeIgniter Projects - Blog";
    if($this->getLastUrl() == 'blog'){
        $data["result"] = $this->blog_model->getBlogs();
        $this->load->view("view_blog", $data);  
    }else{
        $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);
        //check for reply
        $url =$_SERVER['REQUEST_URI'];
        $getLast = explode("/", $url);
        $last = end($getLast);
        if($last == 'reply'){
            $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)
            {
                $this->blog();
            }
            else
            {
                $msg = 'Message sent.';
                $this->blog_model->addBlogComment();
                $this->blog();
            }
        }

    }
}

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

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

2 个答案:

答案 0 :(得分:2)

我刚刚在代码中找到了错误的循环。循环将没有退出,它将再次返回。

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

它将始终返回false值,因此它将执行并执行无循环结束。

答案 1 :(得分:1)

尝试构建你的控制器:

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