CodeIgnitor Add to Cart does not insert data in Cart array where name has a special character


CodeIgnitor Add to Cart does not insert data in Cart array where name has a special character



I am trying to integrate add to cart in CodeIgnitor. Now the problem is that whenever I try to add a data to the cart it only inserts data whose name in the database field does not have a special character and ignores data whose name in the database field has a special character. For example, if the product name coming from database is Jeans & Top it will ignore it whereas it will accept if it is Jeans Top instead. I tried using & instead of & in the database but same problem. Do I need to escape it somewhere in the controller? If yes, how? I am new to CI. Please help me.



Controller:


public function add() {
$id = $this->input->post('id');
$product = $this->products_model->get($id);

$data = array(
'id' => $id,
'name' => $product->pro_name,
'qty' => 1,
'price' => $product->pro_price,
);
// echo "<pre>";
// print_r($data);

if($this->cart->insert($data) == TRUE) {
redirect('cart/show');
} else {
die('ERROR ADDING CART');
}
}



Model:


public function get($id) {
$results = $this->db->get_where('products', array('pro_id' => $id));
return $results->row();
}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift