[eluser]subhashramesh[/eluser]
Hi all,
I am new to codeigniter and i tried to access databse as follows.
my databse name is 'efo' and and it has table 'sample' with 3 columns namely a,b,c respectively.
CONFIG.PHP settings i changed as follows.
$config['base_url'] = "https://127.0.0.1/CodeIgniter_1.7.1/";
$config['rewrite_short_tags'] = TRUE;
DATABSE.PHP settings i changed as follows.
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "";
$db['default']['database'] = "efo";
$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";
AUTOLOAD.PHP i changed settings as follows.
$autoload['libraries'] = array('database');
my model file as Helloworld_model.php as follows.
<?php
class Helloworld_model extends Model {
function Helloworld_model()
{
// Call the Model constructor
parent::Model();
}
function getData()
{
//Query the data table for every record and row
$query = $this->db->get('sample');
if ($query->num_rows() < 0)
{
//show_error('Database is empty!');
}else{
return $query->result();
}
}
}
?>
my controlfile Helloworld.php as follows.
<?php
class Helloworld extends Controller{
function index()
{
$this->load->model('Helloworld_model');
$data['result'] = $this->Helloworld_model->getData();
$data['page_title'] = "CI Hello World App!";
$this->load->view('helloworld_view',$data);
}
}
?>
my view file helloworld_view.php as follows.
<html>
<head>
<title><?=$page_title?></title>
</head>
<body>
<?php foreach($result as $row):?>
<h3><?=$row->a?></h3>
<p><?=$row->b?></p>
<p><?=$row->c?></p>
<br />
<?php endforeach;?>
</body>
</html>
but i am getting error as follows.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Helloworld::$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
could you please anyone solve this problem.