Welcome Guest, Not a member yet? Register   Sign In
White page of death - loading a model
#1

[eluser]überfuzz[/eluser]
I'm trying to load a model from a controller, but I'm getting white page. I can't spot the error...

Code:
function index()
    {
        $this->load->model('public');           //these two rows killes the page and I don't understand why...
        $this->data['brev'] = $this->public->get_brev();
        $this->data['content'] = "hem";
        $this->load->view('templates/standard', $this->data);
    }

public.php:
Code:
function get_brev()
    {
        $this->db->select('rubrik');
        $this->db->select('text_unparsed');
        $this->db->from('manadsbrev');
        $this->db->order_by('tid', 'desc');
        $this->db->limit(1);

        $query = $this->db->get();

        if ($query->num_rows() > 0)
        {
            return $query->result();
        }
        else
        {
            echo "tom";
        }
    }
#2

[eluser]pistolPete[/eluser]
Does public.php only contain that one function? It should be a full model class.

Enable error_reporting() in your index.php to see which PHP errors occur:
Code:
error_reporting(E_ALL);
#3

[eluser]jedd[/eluser]
Also -
[quote author="überfuzz" date="1257131604"]
[code]
$this->data['brev'] = $this->public->get_brev();
[code]
[/quote]

- should use upper-case model name, viz $this->Public->get_brev(), as described in the user guide.

Also - of all the words you could use to name a class, a reserved word is probably not the absolute smartest choice.
#4

[eluser]überfuzz[/eluser]
[quote author="jedd" date="1257132512"]Also -
- should use upper-case model name, viz $this->Public->get_brev(), as described in the user guide.

Also - of all the words you could use to name a class, a reserved word is probably not the absolute smartest choice.[/quote]

I never read that part of the user_guide. ;-)

I got one thing to say about public, let's keep it quite, it is embarrassing!




Theme © iAndrew 2016 - Forum software by © MyBB