[eluser]stormbytes[/eluser]
I'm trying to error-trap the details() method below, so that prior to outputting a view, it checks (against the database) to see if the args are valid. First it checks to see if args have been provided altogether, and if not, it redirects the user to the catalog() controller. This part works fine, which is all the more baffling!
Next, it checks to see if the details() method's args are indeed valid by calling a model-method. This is the part that generates an error. I don't understand why this is happening as the $this->load->view statement only appears if BOTH conditions are not met. So as far as I see it, there's no output prior to that.
Error Message:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: models/assets_mod.php
Line Number: 43
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Users/iMac/Dropbox/htdocs/bin/ci_arrow/system/libraries/Exceptions.php:166)
Filename: helpers/url_helper.php
Line Number: 539
Class Method details()
Code:
function details($asset_id = array()) {
if(!count($asset_id) > 0) {
redirect(base_url(). 'catalog', 'refresh');
} elseif(!$this->assets_mod->get_asset_url($asset_id)) {
redirect(base_url(). 'catalog', 'refresh');
} else {
// Page Defaults
$data['page_title'] = "Details";
$data['page_desc'] = $this->assets_mod->get_asset_name($asset_id);
$data['asset_url'] = $this->assets_mod->get_asset_url($asset_id);
$data['content'] = 'view_asset';
$this->load->view('template', $data);
}
}
model-Method get_asset_url()
Code:
function get_asset_url($asset_id) {
if(count($asset_id) == 1) {
$q = $this->db->select("asset_url");
$q = $this->db->where("asset_id", $asset_id);
$q = $this->db->get("Assets", 1);
if($q->num_rows() == 1)
foreach($q->result() As $row)
$data = $row->asset_url;
return $data;}
else {
return FALSE;
}
}