我正在使用codeigniter框架,当我提交发布到我的数据库时,我一直收到此错误。
控制器
public function profilePic()
{
if ($this->session->userdata('userLogin')) {
$user_id = $this->session->userdata('user_id');
$data = array();
if (isset($_POST['add'])) {
$pic = $this->input->post('profileFace');
$front = $this->input->post('frontView');
$left = $this->input->post('leftView');
$right = $this->input->post('rightView');
$back = $this->input->post('backView');
$updtResult = $this->main_model->updateProfilePic($pic,$front,$left,$right,$back,$user_id);
redirect("userProfile");
} else {
$data['userdata'] = $this->main_model->getUserData();
$this->load->view("frontend/ajax-view", $data);
}
} else {
redirect("/fitness");
}
}
模型
function updateProfilePic($pic,$front,$left,$right,$back,$user_id) {
$check = $this->getUserData();
if(count($check)!=0)
{
if($pic != "")
{
$data['image'] = $pic;
}
if($front != "")
{
$data['front_view'] = $front;
}
if($left != "")
{
$data['left_view'] = $left;
}
if($right != "")
{
$data['right_view'] =$right;
}
if($back != "")
{
$data['back_view'] = $back;
}
// pr($data);
$this->db->where('user_id',$user_id);
$result = $this->db->update('fitness_users', $data);
}
return $result;
}
答案 0 :(得分:1)
您可以使用 private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.tab_11) {
mViewPager.setCurrentItem(0);
} else if (menuItem.getItemId() == R.id.tab_22) {
mViewPager.setCurrentItem(1);
} else if (menuItem.getItemId() == R.id.tab_33) {
mViewPager.setCurrentItem(3);
} else if (menuItem.getItemId() == R.id.setting_nav) {
Intent nextIntent = new Intent(getApplicationContext(), settingActivity.class);
startActivity(nextIntent);
}
mDrawerLayout.closeDrawers();
return true;
}
});
方法更新数据,并使用set
isset()