Welcome Guest, Not a member yet? Register   Sign In
Call to a member function on a non-object
#1

[eluser]spagi[/eluser]
Hi i have a problem
Fatal error: Call to a member function on a non-object in /3w/zaridi.to/s/spagi/system/application/views/rubrika_detail.php on line 27

Code:
function detail(){
  $this->db->where('id_rubriky', $this->uri->segment(3));
  $data['query']=$this->db->get('rubriky');
  
  $this->db->where('id_rubrik', $this->uri->segment(3));
  $data['diskuze']=$this->db->get('rubdisk');
  $this->load->view('rubrika_detail', $data);
  
  
  $this->db->select('*');
  $this->db->from('klienti');
  $this->db->join('rubdisk','autor','autor=id_klienta');
  $data['ut']=$this->db->get();
  $this->load->view('rubrika_detail', $data);
  }

Code:
<?php
include_once "hlavicka.php";

?>

<div id="welcome" class="post">

&lt;?
if ($query->num_rows() > 0){
$row = $query->row();
?&gt;

    <h1 >&lt;?echo $row->seznam;?&gt;</h1>
    <h2>Citace literatury</h2>
    <p> &lt;? echo $row->citace?&gt;  </p>
    <h2>Postoj autora</h2>
    <p>&lt;?echo $row->postoj?&gt;</p>
&lt;?
}

?&gt;
     <h2 align="center">Diskuze:</h2>
     <hr>
&lt;? if ($diskuze->num_rows() > 0){
$row = $diskuze->row();

if ($ut->num_rows() > 0){ ////line 27
$ukaz = $ut->row();
?&gt;
&lt;?echo $ukaz->jmeno?&gt;
<p>&lt;? echo $row->obsah ?&gt;</p>
&lt;?
}
exit;
}

exit;?&gt;
</ul>



&lt;?
include_once "paticka.php";
?&gt;


Can anyone explain what is wrong?
#2

[eluser]ConnorD[/eluser]
I am not exactly sure, but you may want to try in your view rather than having $row = $query->row(), try $row = $query->result(). That's what I use anyway.

If that doesn't work as it is, then I would suggest that you put the results into a foreach statement to loop through all the results:

Code:
foreach($query->result() as $row){
// code in here
}
#3

[eluser]spagi[/eluser]
I do not know what is wrong, but it still does not work :-S
#4

[eluser]ConnorD[/eluser]
also, make sure that you have loaded the Database library. I suppose that could be the problem...
#5

[eluser]ray73864[/eluser]
why are you loading the same view twice in the same function? also, the error that you are getting points to a problem with your sql query itself, basically it isn't returning anything so when you try to pull something out it errors out.
#6

[eluser]lmv4321[/eluser]
You are calling the view for the first time before setting $data['ut']. Try removing the view call after the line $data['diskuze']=$this->db->get('rubdisk');




Theme © iAndrew 2016 - Forum software by © MyBB