CodeIgniter Forums
trouble shooting - 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: trouble shooting (/showthread.php?tid=22148)

Pages: 1 2


trouble shooting - El Forum - 08-31-2009

[eluser]subhashramesh[/eluser]
Hi all,
I write one simple datbase access application to retive data using CI framework,but i am
getting error as

Fatal error: Call to a member function _assign_libraries() on a non-object in C:\xampp\htdocs\CodeIgniter_1.7.1\system\libraries\Loader.php on line 1038
could you please help to fix above error.


trouble shooting - El Forum - 08-31-2009

[eluser]LuckyFella73[/eluser]
Please post the code of your controller otherwise even
the CI nurds can't help you with you problem.


trouble shooting - El Forum - 08-31-2009

[eluser]subhashramesh[/eluser]
thanks for your reply.I am giving my model,controler,view functions.could you please fix coming error.
my model is
<?php
class AccessDatabase_model extends Model {
function AccessDatabase_model()
{
parent::Model();
}
function getData()
{
$query = $this->db->get('sample');
if ($query->num_rows() < 0)
{
show_error('Database is empty!');
}
else{
return $query->result();
}
}

}
?&gt;
my controler is
&lt;?php
class AccessDatabase extends Controller{
function AccessDatabase()
{
parent::Controller();
}

function index()
{
$this->load->model('AccessDatabase_model');

$data['result'] = $this->AccessDatabse_model->getData();
$data['page_title'] = "CI Hello World App!";
$this->load->view('AccessDatabase_view',$data);
}
}
?&gt;
my view is
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?=$page_title?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php foreach($result as $row):?&gt;
<h3>&lt;?=$row->a?&gt;</h3>
<p>&lt;?=$row->b?&gt;</p>
<p>&lt;?=$row->c?&gt;</p>
<br />
&lt;?php endforeach;?&gt;
&lt;/body&gt;
&lt;/html&gt;
i tried to use this url:https://localhost/CodeIgniter_1.7.1/index.php/AccessDatabase
I am getting error as

A PHP Error was encountered
Severity: Notice
Message: Undefined property: AccessDatabase::$Ok1
Filename: libraries/Loader.php
Line Number: 1038

Fatal error: Call to a member function _assign_libraries() on a non-object in C:\xampp\htdocs\CodeIgniter_1.7.1\system\libraries\Loader.php on line 1038



trouble shooting - El Forum - 08-31-2009

[eluser]LuckyFella73[/eluser]
I didn'd have a look at your model and view file but
your controller should more look like that:

Code:
&lt;?php  
class AccessDatabase extends Controller
{
    function AccessDatabase()
    {
        parent::Controller();
        $this->load->database();
        $this->load->model('AccessDatabase_model', 'AccessDatabase_model', true);
    }

    function index()
    {
        $data['result'] = $this->AccessDatabse_model->getData();
        $data['page_title'] = 'CI Hello World App!';
        $this->load->view('AccessDatabase_view',$data);
    }
}
?&gt;

Please use the "code" tags when posting - it makes your code more readable.


trouble shooting - El Forum - 08-31-2009

[eluser]LuckyFella73[/eluser]
Maybe your model should look like:
Code:
&lt;?php  
class AccessDatabase_model extends Model
{
    function AccessDatabase_model()
    {
        parent::Model();
    }
    
    function getData()
    {
        $query = $this->db->get('sample');
        if ($query->num_rows() > 0)
        {
            return $query;
        }
        else
        {
            return false;
        }
    }
}
?&gt;



trouble shooting - El Forum - 08-31-2009

[eluser]subhashramesh[/eluser]
Thanks for your reply,i changed controler file as suggetsted by you.But still i am getting same error.may i know what's code taggs,how its helpful to increase redablity?
could you please solve error in any other way?


trouble shooting - El Forum - 08-31-2009

[eluser]LuckyFella73[/eluser]
[quote author="subhashramesh" date="1251724262"]may i know what's code taggs,how its helpful to increase redablity?
could you please solve error in any other way?[/quote]

When you post code here you click at the "code" button on top of
the editor. Then you get a opening an a closing code tag where you
paste your code in between. Then your code looks like my code examples.

Did you check my model-code?


trouble shooting - El Forum - 08-31-2009

[eluser]subhashramesh[/eluser]
Hi,
thanks for dedicating time to reply my quries.still i am unable to get by placing model as tell by you.kindly look through it.


trouble shooting - El Forum - 08-31-2009

[eluser]n0xie[/eluser]
Quote:Class names must have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class.

http://ellislab.com/codeigniter/user-guide/general/models.html


trouble shooting - El Forum - 08-31-2009

[eluser]narendran[/eluser]
hi,
I’m doing Cart system like products,category,order etc.for this i have to write code for
admin area to edit,delete,add,giving authorization to customers to login or not.


frnds, I’m Beginner of CI.so help me how to do this by CI.give me reference sites.sample codes also.
hope i will get a Good response from u.

thanks,

Narendran