Welcome Guest, Not a member yet? Register   Sign In
Keen to help another newb with the news tutorial?
#1

[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');
        }
}
#2

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

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

Yes - PHP 5.3.2
#4

[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.
#5

[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.
#6

[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.
#7

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

[eluser]sjaxso[/eluser]
notepad++

It's fixed now, as above. Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB