CodeIgniter Forums
White page of death - loading a model - 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: White page of death - loading a model (/showthread.php?tid=24150)



White page of death - loading a model - El Forum - 11-01-2009

[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";
        }
    }



White page of death - loading a model - El Forum - 11-01-2009

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



White page of death - loading a model - El Forum - 11-01-2009

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


White page of death - loading a model - El Forum - 11-01-2009

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