[eluser]Unknown[/eluser]
I've been using flash data a lot recently with no problems but I've come up against something that is driving me crazy.
What I want do do is set some flash data which is the result of a DB query.
Here is the controller:
Code:
//get the name based on the ID
$unitname = $this->game_model->getUnitName($_POST['type']);
//make a description to put into flashdata
$desc = 'You bought ' . $_POST['num'] .' '. $unitname;
//set the flashdata
$this->session->set_flashdata('info', $desc);
//go back to where we started
redirect ("game/bleh");
and here is the model:
Code:
function getUnitName($unitID)
{
if (empty($unitID)){return false;}
$query = $this->db->query(' SELECT unitName FROM units WHERE unitID = "'. $unitID .'"');
$result = $query->row();
return $result->unitName;
}
When it hits set_flashdata is just destroys the session and redirects me back to my login page. I tried just echoing the $desc and it works perfectly with that, I also tried just using the $_POST variables and that worked too. It just breaks when I try and use the result of a query in the description. I searched the forum quite a bit and the only similar problem I could find was someone that was inserting too much data into the flashdata. In my case it's only a very short string (one short sentence) so this cannot be the case.
Am I just a complete idiot (very possible) and doing something stupid here?
Thanks