CodeIgniter Forums
Keen to help another newb with the news tutorial? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Keen to help another newb with the news tutorial? (/showthread.php?tid=56661)



Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]sjaxso[/eluser]
I'm struggling a bit with a 500 error. I'm sure it's something dumb but I can't fix it:

PHP Parse error: syntax error, unexpected T_PUBLIC in /var/www/vhosts/***.com/ci/application/controllers/news.php on line 11

Here's my news.php

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

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();
                $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'] = $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');
        }
}



Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]jprateragg[/eluser]
Are you using PHP5?


Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]sjaxso[/eluser]
[quote author="jprateragg" date="1357782457"]Are you using PHP5?[/quote]

Yes - PHP 5.3.2


Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]jprateragg[/eluser]
I'm assuming this is line 11?

Code:
public function index()

There's something making this line choke. Is it possible some "invisible" character is between the closing bracket for your __construct() function and the "public" word? Try deleting the white space between the closing bracket and the start of your index function and see if that fixes it. Everything looks correct.


Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]sjaxso[/eluser]
Yep, that's line 11. I went through and checked for invisible characters and stripped out the indenting, but still the same error.

Thanks for looking though.


Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]sjaxso[/eluser]
OK, I typed it out by hand rather than copypasting and problem has gone away.

Replaced with another problem of course, but I'll hunt it down!

Thanks again.


Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]jprateragg[/eluser]
What editor are you using to edit this? Notepad, Notepad++?


Keen to help another newb with the news tutorial? - El Forum - 01-09-2013

[eluser]sjaxso[/eluser]
notepad++

It's fixed now, as above. Thanks!