Welcome Guest, Not a member yet? Register   Sign In
how to deal with this? Undefined property: stdClass::$writer
#1

[eluser]Unknown[/eluser]
Hi I'm new in CI, I was working on with my form when I got stuck with this error:

my model:

public function search_entry($subject, $message)
{

$this->db->select('index', 'subject', 'writer', 'registerTime');
$this->db->from('t_board');
$this->db->like('subject', $subject);
$q = $this->db->get();
return $q->result();
}

my controller:

function index()
{
$this->load->model('DbSimplex');
$data['query'] = $this->DbSimplex->search_entry($subject = $this->input->post('subject'), $message = $this->input->post('message'));

if($this->input->post('search'))
{
$this->subject = $this->input->post('subject');
$this->message = $this->input->post('message');
echo $this->subject;
echo $this->message;
$data['query'] = $this->DbSimplex->search_entry($subject = $this->input->post('subject'), $message = $this->input->post('message'));
$this->load->view('board', $data);
}
$this->load->view('board', $data);
}

my view: board.php


<?php foreach($query as $value){ ?>
<tr>
<td>&lt;?php echo $value->index; ?&gt;</td>&lt;!--post index. retrieved from db--&gt;
<td class="subject">
&lt;input type="checkbox" id="" name="" value="" title="" /&gt;
<a href="#">&lt;?php echo $value->subject; ?&gt;</a>
</td>&lt;!--subject or post title. retrieved from db--&gt;
<td>&lt;?php echo $value->writer; ?&gt;</td>&lt;!--writer's name. retrieved from db--&gt;
<td>&lt;?php echo $value->registerTime; ?&gt;</td>&lt;!--written date. retrieved from db. Timestamp in DB. display format:dd/mm/yyyy--&gt;
</tr>
&lt;?php } ?&gt;

everytime I hit the search button this error comes out in my table:

A PHP Error was encountered

Severity: Notice
Message: Undefined property: stdClass::$writer
Filename: views/board.php
Line Number: 49

I'm totally lost I don't know what went wrong with my code... I would appreciate your help I've attached a printscreen of this error message

thank you so much in advance
#2

[eluser]Unknown[/eluser]
*Problem solve*

the problem lies within my select procedure which is:

select('field1', 'field2', 'field3' , 'field4')

this is what I thought, but it seems that supposedly the preceding of my field1 isn't another
field but the $value it contains.

public function search_entry($subject, $message)
{

$this->db->select('*');
$this->db->from('t_board');
$this->db->like('subject', $subject);
//$this->db->where('message', $vMessage);
$q = $this->db->get();
return $q->result();
}




Theme © iAndrew 2016 - Forum software by © MyBB