Jump to content

Codeigniter - Public_T Error


stijn0713

Recommended Posts

Hello, i'm following the codeIgniter tutorial on 'news section' which basically retrieves news items records from database and shows them on a page but according to the MVC principle.

 

Therefore, i just copy paste this code in the news controller:

 

<?php
class News extends CI_Controller {
public function __construct()
{
 parent::__construct();
 $this->load->model('news_model');
}
public function index()
{
 $data['news'] = $this->news_model->get_news();
}
public function view($slug)
{
 $data['news'] = $this->news_model->get_news($slug);
}
}
public function index()
{
$data['news'] = $this->news_model->get_news();
$data['title'] = 'News archive';
$this->load->view('templates/header', $data);
$this->load->view('news/index', $data);
$this->load->view('templates/footer');
}
public function view($slug)
{
$data['news_item'] = $this->news_model->get_news($slug);
if (empty($data['news_item']))
{
 show_404();
}
$data['title'] = $data['news_item']['title'];
$this->load->view('templates/header', $data);
$this->load->view('news/view', $data);
$this->load->view('templates/footer');
}

 

But i get the following error then: Parse error: syntax error, unexpected T_PUBLIC in C:\wamp\application\controllers\news.php on line 21

 

I haven't worked much with OOP but it seems no problem to declare those index and view functions public, right? else the tutorial must be wrong, which i rarely doubt. So what is the problem then?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.