如何在mysql数据库中输入双引号

时间:2014-04-11 07:28:22

标签: php mysql codeigniter

当我尝试在表中输入双引号时,它会显示一些db错误。 我尝试使用stripslashes和mysql_real_escape_string,但它无法进入表格。

控制器

function ConfirmOrder($arr) {
    $confirmation_number = substr(number_format(time() * rand(),0,'',''),0,10); 
    $ord_no = substr(number_format(time() * rand(),0,'',''),0,2); 
    $this->load->model('users_model');
    $this->users_model->ConfirmOrder($arr,$arr['order_id'],$confirmation_number,$ord_no);
    $confirm_status = array('status' => 'true', 'message' => 'Order Confirmed Successfully');

    echo json_encode($confirm_status);
}

模型

function ConfirmOrder($arr,$order_id,$confirmation_no,$ord_no) {
    $data = array(
        'order_number'        => $ord_no.strtotime(date("Y-m-d H:i:s")),
        'order_date'          =>  date("Y-m-d H:i:s"),
        'confirmation_number' =>  $confirmation_no
    );

    $this->db->where('order_id',$order_id);
    $this->db->update('mun_order_master',$data);

    if($arr['my_picks']) {
        $pick_name =  mysql_real_escape_string($arr['pick_name']);

        $data1 = array(
            'user_id'   => $arr['user_id'],
            'order_id'  => $order_id,
            'pick_name' => $pick_name,
            'add_date'  =>  date("Y-m-d H:i:s")
        );

        $this->db->insert('mun_my_picks', $data1);
        return $this->db->insert_id();
    }

    return true;
}

我使用的JSON

$json='{"function":"ConfirmOrder","parameters": "order_id": "7","user_id": "25","pick_name": "SPick","my_picks": "Y"},"token":""}'; 

0 个答案:

没有答案