Welcome Guest, Not a member yet? Register   Sign In
A Database Error Occurred
#1

[eluser]bsrbvr[/eluser]
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

SELECT `offer_title`, `off_url` FROM (`adp_offer`) WHERE `merchant_id` =


Hi
I am getting above error when executing following code.

public function get_merchantoffers($slug = FALSE)
{

$this->db->select('merchant_id');
$query = $this->db->get_where('adp_merchant', array('merchant_name' => $slug ));
$this->db->select('offer_title,off_url');
$result = $this->db->get_where('adp_offer', array('merchant_id' => $query));
return $result->row_array();
}


I want to pass the value available in query variable to get_where function.
#2

[eluser]InsiteFX[/eluser]
Try this
Code:
public function get_merchantoffers($slug = FALSE)
{
   $this->db->select('merchant_id');
   $query = $this->db->get_where('adp_merchant', array('merchant_name' => $slug ));
   $row = $query->result();
   $this->db->select('offer_title, off_url');
   $result = $this->db->get_where('adp_offer', array('merchant_id' => $row->merchant_id));
   return $result->row_array();
}




Theme © iAndrew 2016 - Forum software by © MyBB