1

codeIgniter でこの致命的なエラー メッセージが表示されます。同じ質問に対するいくつかの回答を既に試しました。

私はすでにphp.iniを設定しています

    最大実行時間 = 300
    最大入力時間 = 600
    メモリ制限 = 128M

しかし、それでも同じ Fatal エラー メッセージが表示されます。問題がコードにあるのか、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 関数

    関数 addBlogComment(){
    $data=配列(
    'blog_id'=> $this->input->post('blog_id'),
    '名前' => $this->input->post('名前'),
    'email' => $this->input->post('email'),
    'メッセージ' => $this->input->post('メッセージ'),
    'created' => date('Ymd H:i:s')
    );

    $this->db->insert('comment',$data);
    }

4

2 に答える 2

2

コードに間違ったループがあることがわかりました。ループには出口がなく、再び元に戻ります。

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

常に false 値を返すため、実行され、ループの終わりは実行されません。

于 2013-03-26T06:50:32.160 に答える
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 ) );
            }
        }
    }
}
于 2013-02-06T11:39:46.237 に答える