• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error 'Undefined property' when loading model to controller

#1
[eluser]Tortoise[/eluser]
Hello to everyone!

I have the code:
news.php:
Code:
<?php
  class News extends Controller
  {
    public function ru()
    {
      $data['xml_lang'] = 'ru';
      $data['title'] = 'Официальный сайт брутал-дэт группы Fleshbomb - Новости';      
      /*$this->load->helper('url');
      $data['main'] = anchor('news/ru', 'Главная');*/
      $data['published'] = 'Опубликовано';
      $this->load->model('news_model');
      $data['news'] = $this->news_model->get_last_three_entries($data['xml_lang']);
      $this->load->view('newsview', $data);
    }
    
    public function en()
    {
      $data['xml_lang'] = 'en';
      $data['title'] = 'Fleshbomb brutal-death band Official Site - News';
      /*$this->load->helper('url');
      $data['main'] = anchor('news/en', 'Main');*/
      $data['published'] = 'Published';
      $this->load->model('news_model');
      $data['news'] = $this->news_model->get_last_three_entries($data['xml_lang']);
      $this->load->view('newsview', $data);
    }
  }
?>
news_model.php:
Code:
<?php
  class News_model extends Model
  {
    public function __construct()
    {      
            parent::Model();
            $this->load->database();
    }
    
    public function get_last_three_entries($lang)
    {      
      $sql = "SELECT p_date AS date, p_title_$lang AS title, p_content_$lang AS content FROM site_news LIMIT 3";            
      $query = $this->db->query($sql);
      return $query->result_array();
    }
  }
?>
and newsview.php:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="&lt;?php echo $xml_lang; ?&gt;" lang="&lt;?php echo $xml_lang; ?&gt;"&gt;
&lt;head&gt;
    &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
  &lt;meta name="keywords" content="brutal-death, grindcore, grind-core, goredeath, gore-death, fleshbomb, nosorog" /&gt;
  &lt;meta name="description" content="Moscow gore-death band official site. Full discography, biography, gigs, videos" /&gt;
  &lt;link rel="stylesheet" type="text/css" href="../../system/application/media/css/style.css" /&gt;
&lt;/head&gt;  
&lt;body&gt;
    <div id="sidebar-left">
        <ul id="menu-list">
            <li><a href="#">Menu item</a></li>
        </ul>
    </div>
  &lt;?php foreach($news as $item): ?&gt;
  <div class="news-block">    
    <h3 class="news-title">&lt;?php echo $item['title']; ?&gt;</h3>
    <div class="news-date">&lt;?php echo $published . ': ' . date('d.m.Y H:i:s', $item['date']); ?&gt;</div>
    <div class="news-body">&lt;?php echo $item['content']; ?&gt;</div>
    <hr />
  </div>
  &lt;?php endforeach; ?&gt;
&lt;/body&gt;
&lt;/html&gt;
On my local server (MAMP 1.7.1) it works just fine. Even if I used $this->load->model(Uppercase_name) or $this->load->model(lowercase_name).
But when I put it on hosting server I have get error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: News::$news_model
Filename: controllers/news.php
Line Number: 12
Fatal error: Call to a member function get_last_three_entries() on a non-object in /pub/home/artwiko/htdocsfb/dev/system/application/controllers/news.php on line 12
For the /news/ru.html.
And:
Fatal error: Call to a member function get_last_three_entries() on a non-object in /pub/home/artwiko/htdocsfb/dev/system/application/controllers/news.php on line 24
For the /news/en.html
I can't understand what I doing wrong.
Could somebody help please?


Messages In This Thread
Error 'Undefined property' when loading model to controller - by El Forum - 06-07-2008, 09:25 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.