1

I'm working on a CMS website, I have got one issue which I'm trying to fix it from saturday, but im unable to know why such error is coming. I'm getting an error like this

Error: A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: views/services.php

Here I'm using two values one is results and another is results, but I'm still not getting why it's showing error as Trying to get property of non-object. more over I used the same concept in my another page, which is working fine but I don't know why I'm getting error like this here. Please can anyone guide me in this.

This is my Home.php(Controller)

    //-----------Services page-------------

        public function services()  
        {  
            $this->load->helper('url');
            $this->load->view('header');
            $data['results'] = $this->Contact_model->service_us_getvalue();
            $data['resultss'] = $this->Contact_model->service_us_getvalue1();
            $this->load->view('services',$data); 
            $this->load->view('footer');                    
        }

This is my Contact_model.php

    //--------Service----------


    //query to select the different rows
    function service_us_getvalue()
    {
        return  $this->db->get('service_us')->row();
    }

    function service_us_getvalue1()
    {
        return  $this->db->get("service_us WHERE type='Section_2'")->result();
    }

Service.php

    //   This is how it looks when the website is in static mode this one I'm trying to convert dynamic.  

    <div class="col-md-6">
    <div class="media">
      <ul>
        <li>
          <div class="media-left">
            <i class="fa fa-pencil"></i>
          </div>
          <div class="media-body">
            <h4 class="media-heading">Web Development</h4>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum erat libero, pulvinar tincidunt leo consectetur eget.</p>
          </div>
        </li>
        <li>
          <div class="media-left">
            <i class="fa fa-book"></i>
          </div>
          <div class="media-body">
            <h4 class="media-heading">Responsive Design</h4>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum erat libero, pulvinar tincidunt leo consectetur eget.</p>
          </div>
        </li>
        <li>
          <div class="media-left">
            <i class="fa fa-rocket"></i>
          </div>
          <div class="media-body">
            <h4 class="media-heading">Bootstrap Themes</h4>
            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum erat libero, pulvinar tincidunt leo consectetur eget.</p>
          </div>
        </li>
      </ul>
    </div>
  </div>-->

    <?php
        if (isset($resultss))
        {
            echo $resultss->description; 
        }
    ?>
Pradeep
  • 9,667
  • 13
  • 27
  • 34
keerthi patil
  • 123
  • 2
  • 13

2 Answers2

2

Hope this will help you :

Use row() instead of result() in service_us_getvalue1 method

Your model method service_us_getvalue1 should be like this :

function service_us_getvalue1()
{
  $this->db->where('type' , 'Section_2');
  return  $this->db->get("service_us")->row();
}
Pradeep
  • 9,667
  • 13
  • 27
  • 34
0

Try this might help you

<?php
        if (isset($resultss))
        {
            echo $resultss['description']; 
        }
    ?>
Deepak
  • 614
  • 1
  • 7
  • 20