php - Trying to get property of non-object (2) -


i keep getting errror:

trying property of non-object.

the problem sql date field called 'sterfdatum' when field in db filled in example '1988-12-01 15:13:14'. there no problem code. when field '0000-00-00 00:00:00', , try out db error showed.

this model:

<?php  public function get_artist($last_name = null , $front_name = null, $language = 'nl')     {         // infonl language language can used in view file         if($language == 'nl')         {             $this->db->select('naam, voornaam, geboortedatum, geboorteplaats, foto, infonl language, sterfdatum')                  ->from('kunstenaar')                  ->where('naam', $last_name)                  ->where('voornaam', $front_name)                  ->limit(1);              return $this->db->get()->row();         }         elseif($language == 'en')         {             $this->db->select('naam, voornaam, geboortedatum, geboorteplaats, foto, infoen language, sterfdatum')                  ->from('kunstenaar')                  ->where('naam', $last_name)                  ->where('voornaam', $front_name)                  ->limit(1);              return $this->db->get()->row();         }      } 

in view have

if($artist->sterfdatum != '0000-00-00 00:00:00')        {            $birthyear = date('y', strtotime($artist->geboortedatum));            $dieyear = date('y', strtotime($artist->sterfdatum));         } $artist->sterfdatum != '0000-00-00 00:00:00' , here problem. 

if(isset($artist->sterfdatum) && $artist->sterfdatum != '0000-00-00 00:00:00') {  $birthyear = date('y', strtotime($artist->geboortedatum));  $dieyear = date('y', strtotime($artist->sterfdatum)); } 

should work


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -