Php 使用codeigniter 3将数据插入数据库时,页面变为空白
我正在将数据插入数据库,当它插入时,页面变为空白,然后返回 这是我的密码:Php 使用codeigniter 3将数据插入数据库时,页面变为空白,php,mysql,codeigniter,Php,Mysql,Codeigniter,我正在将数据插入数据库,当它插入时,页面变为空白,然后返回 这是我的密码: if ( ! $this->upload->do_upload('post_image')) { $this->session->set_flashdata('post_message', $this->upload->display_errors()); $this->session->set_flashdata('post_message_class',
if ( ! $this->upload->do_upload('post_image'))
{
$this->session->set_flashdata('post_message', $this->upload->display_errors());
$this->session->set_flashdata('post_message_class', 'alert-danger');
redirect('/user/profile/'.$identity, 'refresh');
}
else
{
$uploaded = $this->upload->data();
$post_text = "";
// insert pos
if(isset($uploaded['file_name']) && $uploaded['file_name'] == 0)
{
$post_text = '<img src="/uploads/images/'.$uploaded['file_name'].'" width="251px" alt="'.$uploaded['raw_name'].'" /><br>'.$this->input->post('post_text');
}
else
{
foreach ($uploaded as $images)
{
$post_text .= '<img src="/uploads/images/'.$images['file_name'].'" width="251px" alt="'.$images['raw_name'].'" />';
}
$post_text .= $this->input->post('post_text');
}
$query = $this->user_model->insert_user_posts($this->input->post('poster_id'), $this->input->post('profile_id'), $this->input->post('post_type'), $post_text);
$this->session->set_flashdata('post_message', 'Image has been posted!');
$this->session->set_flashdata('post_message_class', 'alert-success');
redirect('/user/profile/'.$identity, 'refresh');
}
此外,我使用的是:
有没有办法在插入数据库时不让页面显示为空白?您是否遵循了CI3命名约定?是的,我不认为我做了任何不寻常的事情。尝试输入
错误报告(E\u ALL)
并使用exit跟踪错误的确切位置。我的问题可能会更清楚,但我没有收到错误。页面变为空白,将数据插入数据库,然后返回到现有页面。我添加了缓存,这似乎减少了空白页显示的时间。这是意料之中的,因为您使用的是“代码>重定向())/代码>,这意味着页面必须重新加载,并且需要时间来完成。
public function insert_user_posts($poster_id, $profile_id, $post_type, $post_text)
{
// Users table.
$data = array(
'poster_id' => $poster_id,
'profile_id' => $profile_id,
'post_type' => $post_type,
'post_text' => $post_text,
'datetime' => time()
);
$this->db->insert($this->tables['users_posts'], $data);
if($this->db->affected_rows() > 0)
{
$this->set_message('upload_successful');
return TRUE;
}
else
{
return FALSE;
}
}