2013-02-06 4 views
1

내 codeIgniter에서 치명적인 오류 메시지가 표시됩니다. 이미 동일한 질문이있는 답변을 시도했습니다. 문제가 내 코드 또는 PHP 설정에있는 경우CodeIgniter 치명적 오류 : 사용 가능한 메모리 크기가 낭비되었습니다.

이미 내 php.ini 파일

 

    max_execution_time = 300 
    max_input_time = 600 
    memory_limit = 128M 

를 설정 한하지만 여전히 내가 같은 치명적인 오류 메시지를 받고 있어요, 난 모르겠어요. 여기

는 일부 내 코드의 컨트롤러 :

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

+0

문제는 'addBlogComment()'함수 코드를 공유하는 것이 어떻습니까? –

+0

오류의 코드 줄은 무엇입니까? – Jeemusu

+0

나는 그것이 치명적인 오류 메시지를 받고있는 유효성 검사를 통과하지 못하기 때문에 addBlogComment에서 온 것 같지 않습니다. 하지만 어떤 방식 으로든 추가하겠습니다. – khatz0406

답변

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

도움을 주셔서 감사합니다. – khatz0406

+0

검색어 확인 – Henry8

2

. 루프는 종료가 없으며 다시 뒤집습니다.

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

항상 거짓 값을 반환하므로 루프가 끝나지 않고 실행됩니다.