Welcome Guest, Not a member yet? Register   Sign In
$this->gb->get->('entries') Problem
#1

[eluser]GamingFusion[/eluser]
I'm getting this error, I'm completing the CodeIgniter tutorials. I was wandering if i was doing something wrong.

Quote:Fatal error: Call to a member function get() on a non-object in /home/.maybelle/gfadmin/site.gamingfusion.net/system/application/controllers/feed.php on line 14

to see the actual page with the error go to GamingFusion Site
#2

[eluser]GamingFusion[/eluser]
heres my controller

Code:
1| <?php
2|
3| class Feed extends Controller {
4|    
5|    function Feed()
6|    {
7|        parent::Controller();
8|    }
9|
10|    function index ()
11|    {
12|        $data['title'] = "GamingFusion | Feed";
13|        $data['heading'] = "The Feed";
14|        $data['query'] = $this->db->get('entries');
15|        $this->load->view('feed', $data);
16|    }
17|    
18| }
19|
20| ?>
#3

[eluser]tomcode[/eluser]
[quote author="GamingFusion" date="1240268294"]heres my controller

Code:
14|        $data['query'] = $this->db->get('entries');
[/quote]

You try to call the function get() of a object that is not declared on line 14, so I guess You have not loaded the database ($this->db)
#4

[eluser]GamingFusion[/eluser]
well i am autoloading the database core library

Code:
$autoload['core'] = array('database');

is that code right and is there anything else i have to do yet, i have also setup the database file.

Code:
$db['default']['hostname'] = "hostname";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "gf_news1";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
#5

[eluser]Dam1an[/eluser]
I'm not sure what version you're using, but the database class is auto loaded under libraries (at least now)
#6

[eluser]tomcode[/eluser]
Try
Code:
$autoload['libraries'] = array('database');

instead of 'core'. autoload core is deprecated. (that's why it is commented out, at least in recent CI versions).

Do You really have
Code:
$db['default']['hostname'] = "hostname";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
#7

[eluser]GamingFusion[/eluser]
i'm using 1.7.1, if it has changed please tell, because i'm just following the videos like i said that were from 1.3 on the site. he should make new ones.
#8

[eluser]GamingFusion[/eluser]
tomcode no i just changed them for the post, and the core libraries is not even in the config.php file anymore so i added it
#9

[eluser]GamingFusion[/eluser]
ok i got that fixed thanks tomcode, but now i get some more errors with my view file. just to the link i gave in my first post.

heres my view file code

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
&lt;/head&gt;
<h1>&lt;?=$heading?&gt;</h1>

&lt;?php foreach ($query as $row) : ?&gt;

<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>
<hr />

&lt;?php endforeach; ?&gt;

&lt;/body&gt;
&lt;/html&gt;
#10

[eluser]GamingFusion[/eluser]
i forgot heres my controller code

Code:
&lt;?php

class Feed extends Controller {
    
    function Feed()
    {
        parent::Controller();
    }

    function index ()
    {
        $data['title'] = "GamingFusion | Feed";
        $data['heading'] = "The Feed";
        $data['query'] = $this->db->get('entries');
        $this->load->view('feed', $data);
    }
    
}

?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB