【问题标题】:Why I get the error 502为什么我收到错误 502
【发布时间】:2012-03-30 15:05:32
【问题描述】:

我正在使用 codeIgniter

public function add()
{

    if(!$this->session->userdata('id') || !$this->session->userdata('email'))
    {
        echo "please enter before";
        exit();
    }
    $user_id = $this->session->userdata('id');
    $organization = $this->input->post('organization');
    $adress = $this->input->post('adress');
    $responsable = $this->input->post('responsable');
    $doljnost = $this->input->post('doljnost');
    $rab_tel = $this->db->escape($this->input->post('rab_tel'));
    $mob_tel = $this->db->escape($this->input->post('mob_tel'));
    $desc = $this->db->escape($this->input->post('desc'));
    $uslovia = $this->db->escape($this->input->post('uslovia'));
    $ocobennosti = $this->db->escape($this->input->post('ocobennosti'));
    $coupons = $this->input->post('coupons');
    $discount = $this->input->post('discount');
    $category = $this->input->post('category');
    $days = $this->input->post('days');


    if(empty($discount) || empty($adress) || empty($mob_tel) || empty($discount))
    {
        $this->session->set_flashdata('error', 'fill the inputs');
        $data['content'] = $this->load->view('user_add', null, true);
        $this->load->view('layout', $data);
    }
    else
    {
                $this->db->query('INSERT INTO user_adds (`organization`, `adress`,
                `responsable`, `doljnost`, `rab_tel`,
                `mob_tel`,`desc`, `uslovia`, `ocobennosti`, `coupons`, `category`, `end`, `user_id`) VALUES
                ("'.$organization.'", "'.$adress.'", "'.$responsable.'",
                "'.$doljnost.'", "'.$rab_tel.'", "'.$mob_tel.'",
                "'.$desc.'", "'.$uslovia.'", "'.$ocobennosti.'",
                "'.$coupons.'", "'.$category.'", NOW() + INTERVAL '.$days.' DAY, "'.$user_id.'")');
            redirect('/');
    }
}

此方法执行后,当我转到另一个页面时,它会显示此错误

502 网关错误

服务器返回无效或不完整的响应。

我做错了什么??

会话库是自动加载的,我只是传递给这个方法,不需要提交

【问题讨论】:

  • 我也遇到了 502 错误网关问题。我将其范围缩小到它与购物车库有关。您是否找到了解决此问题的方法/解决方法?

标签: php codeigniter frameworks


【解决方案1】:

你刚刚把局部变量和一个插入到 mysql db 中。从未接触过调用 HTTP(客户端)或接受 HTTP(服务器)的东西。

唯一似乎与 HTTP 相关的事情是调用了一个名为重定向的本地函数。 可能问题就在那里。

502 Bad Gateway 通常是在本地 HTTP 传递到后端服务器失败时由反向代理返回。 尝试注释掉 redirect("/") 看看会发生什么

【讨论】:

  • 知道为什么要进行 HTTP 调用吗?面临一个非常相似的问题,并且没有找到任何其他关于任何人看到相同问题的信息。我猜这与重定向功能有关,而不是存储会话数据。
猜你喜欢
  • 1970-01-01
  • 2020-11-05
  • 2015-01-30
  • 2014-02-10
  • 2015-06-27
  • 2013-07-31
  • 1970-01-01
  • 2018-05-22
  • 1970-01-01
相关资源
最近更新 更多