I want get from after click $_POST['name'] and where it with name inserting that get row id for insert in other table, but get following error. What is the cause of the error? How to fix?
$name = $this -> input -> post('name');
$query_re = $this->db->get_where('tour_foreign', array('name' => $name))->row();
$data2 = array();
foreach ($residence_name as $idx => $name) {
$data2[] = array(
'relation' => $query_re->id, //This is line number 58
'hotel_id' => $residence_id[$idx],
'name' => $residence_name[$idx],
);
};
$data222 = $this->db->insert_batch('residence', $data2);
Error:
A PHP Error was encountered
Severity: Notice
Message: Trying
to get property of non-object
Filename: foreign.php
Line
Number: 58
It seems that this database call returns zero rows :
Also consider using num_rows() to check the result of the database call before calling row().