CodeIgniter致命错误:允许的已用字节大小的内存 [英] CodeIgniter Fatal error: Allowed memory size of bytes exhausted
问题描述
我在我的codeIgniter中收到此致命错误消息,我已经尝试了一些具有相同问题的答案。
I'm getting this Fatal Error Message in my codeIgniter, I've already tried some answers which has the same question.
我已经设置了php .ini
I've already set my php.ini
max_execution_time = 300
max_input_time = 600
memory_limit = 128M
但是我仍然收到同样的致命错误消息,我不知道问题出在我的代码还是php设置中。
But still I'm getting the same Fatal error message, I don't know if the problem is in my code or in php settings.
这是控制器中的一些代码:
Here are some my of codes in controller:
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();
}
}
}
}
我的主要功能是在博客中添加新评论,它可以工作,但是它会插入重复的数据,我无法摆脱致命的错误消息。
My main function is to add new comment in a blog, it works but it inserts duplicate data and I cant get rid of the fatal error message.
addBlogComment函数
addBlogComment Function
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);
}
推荐答案
我刚刚发现自己的错误循环码。循环将没有退出,它将再次返回。
I just found out the wrong loop in my code. The loop will has no exit and it will turns back all over again.
if($this->form_validation->run() == FALSE)
{
$this->blog();
}
else
{
$msg = 'Message sent.';
$this->blog_model->addBlogComment();
$this->blog();
}
它将始终返回错误值,因此它将执行且不执行任何结束循环。
it will always return a false value so it will execute and execute no end of loop.
这篇关于CodeIgniter致命错误:允许的已用字节大小的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!