CodeIgniter Forums

Full Version: Keen to help another newb with the news tutorial?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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

El Forum

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

El Forum

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

Yes - PHP 5.3.2

El Forum

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

El Forum

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

El Forum

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

El Forum

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

El Forum

[eluser]sjaxso[/eluser]
notepad++

It's fixed now, as above. Thanks!