stijn0713 Posted September 23, 2012 Share Posted September 23, 2012 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? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 23, 2012 Share Posted September 23, 2012 You have too many } at one point. You have random public functions outside of your class. Indenting properly would help. Quote Link to comment Share on other sites More sharing options...
stijn0713 Posted September 23, 2012 Author Share Posted September 23, 2012 Aha, see i didn't know class member functions had to be written. thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.