Hello all i have a problem that my information is not being sendt to my view file.开发者_StackOverflow社区
it says: Message: Undefined variable: queryWall
my controller is this
function wallShow()
{
$this->load->model('profil_model');
$data['queryWall'] = $this->profil_model->wallGet($this->uri->segment(3));
$data['content'] = 'profil_view';
$this->load->view('includes/template', $data);
}
my model:
function wallGet($name)
{
$this->db->select('profileName', 'wallComment');
$this->db->where('profileName', $name);
$queryWall = $this->db->get('profileWall');
if($queryWall->num_rows() > 0)
{
return $queryWall->result();
} else {
return false;
}
}
and my view file
<?php
if(!isset($queryWall)):
foreach ($queryWall as $wall):
echo $wall->wallComment;
endforeach;
endif;
?>
Even if everything is fine, you'll keep getting this error since you are using the queryWall
variable whenever it's NOT defined!
if(!isset($queryWall))
It should be:
if(isset($queryWall))
But since you are passing the conditional check, then I suppose you have something wrong with your model OR URI segment.
You are not using the correct syntax for
$this->db->select('profileName', 'wallComment');
Adjust it to this:
$this->db->select('profileName,wallComment');
then also enable the out profiler to verify your query is being written correctly by the database class. In your controller, enable the profiler:
$this->output->enable_profiler(true);
This can be inserted anywhere in the controller function.
I agree with ifaour about making sure your if statement is what you meant it to be.
精彩评论