[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">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $xml_lang; ?>" lang="<?php echo $xml_lang; ?>">
<head>
<title><?php echo $title; ?></title>
<meta name="keywords" content="brutal-death, grindcore, grind-core, goredeath, gore-death, fleshbomb, nosorog" />
<meta name="description" content="Moscow gore-death band official site. Full discography, biography, gigs, videos" />
<link rel="stylesheet" type="text/css" href="../../system/application/media/css/style.css" />
</head>
<body>
<div id="sidebar-left">
<ul id="menu-list">
<li><a href="#">Menu item</a></li>
</ul>
</div>
<?php foreach($news as $item): ?>
<div class="news-block">
<h3 class="news-title"><?php echo $item['title']; ?></h3>
<div class="news-date"><?php echo $published . ': ' . date('d.m.Y H:i:s', $item['date']); ?></div>
<div class="news-body"><?php echo $item['content']; ?></div>
<hr />
</div>
<?php endforeach; ?>
</body>
</html>
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?