Welcome Guest, Not a member yet? Register   Sign In
Begginer ask
#1

[eluser]Kentus[/eluser]
Ok, i'm new in this domain, and i want in this topic to expose my problems that i'll receive for this framework.

I buy a domain: http://earth-war.eu/ and i tried to make the samples from video tutorials where i'll learn to make my own blog.

For the first video i've received some errors:
first said that:
Fatal error: Class 'Controller' not found in /home2/earthwar/public_html/Blog/application/controllers/blog.php on line 3

for the next code:
<?php

class Blog extends Controller{

function index()
{
echo'Hello World'
}

}

?>

I replaced Controller() with CI_Controller and worked, but when i tried to create the constructor i received this:

Fatal error: Call to undefined method CI_Controller::CI_Controller() in /home2/earthwar/public_html/Blog/application/controllers/blog.php on line 7

I replaced with Controller but same error undefined method CI_Controller::Controler().
The code:
<?php

class Blog extends CI_Controller{

function Blog()
{
parent::CI_Controller();
}
function index()
{
$data['title']="My Blog Title";
$data['heading']="My Blog Heading";
$data['todo']=array('Clean house','eat lunch','call mom');
$this->load->view('blog_view',$data);
}

}

?>

Please helpSmile i'm a little stuck on this error and i don't know what to do.
Thanks a lot for future help.
One more thing.. if you see errors in my grammar or my exprimation pls correct me if you have timeSmile). Thanks again
#2

[eluser]danmontgomery[/eluser]
You need to use __construct(), not the class name.

Code:
class Blog extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

}

http://ellislab.com/codeigniter/user-gui...llers.html

Quote:If you intend to use a constructor in any of your Controllers, you MUST place the following line of code in it:

Code:
parent::__construct();
#3

[eluser]Kentus[/eluser]
thanks, i was translated on the video and didn't search on that page. sory for my lazy to search in site.
#4

[eluser]Kentus[/eluser]
Ok..now i began the work and i've got another problem.
I've created a login page and after the member_area page is loading, in my session my username variable is empty.
I've tried two sollutions:
First:
This is where my function is define.
function members_area()
{
$data['main_content']='members_area';
$data['username']=$this->session->userdata('username');

$this->load->view('includes/template',$data);
//$this->load->view('members_area');
}

This is my view_page:
<div id="mainContent">

<div id="userPanel">
<h3>Account Details</h3>
Wellcome: &lt;?php $username?&gt;
</div> &lt;!-- se inchide userPanel--&gt;

</div>&lt;!-- se inchide mainContent--&gt;

and second ideea is:
function members_area()
{
$data['main_content']='members_area';

$this->load->view('includes/template',$data);
//$this->load->view('members_area');
}

This is my view_page:
&lt;?php $username=$this->session->userdata('username');
<div id="mainContent">

<div id="userPanel">
<h3>Account Details</h3>
Wellcome: &lt;?php $username?&gt;
</div> &lt;!-- se inchide userPanel--&gt;

</div>&lt;!-- se inchide mainContent--&gt;
Not Works.

above this member_area function i have another function:
function is_logged_in()
{
$is_logged_in=$this->session->userdata('is_logged_in');
if(!isset($is_logged_in)||$is_logged_in !=true)
{
echo 'You don\' have permission to access this page. <a href="../login">Login</a>';
die();
}
}

and works great.
I define my session variables here:
if($query)
{
$data=array(
'username'=>$this->input->post('username'),
'is_logged_in'=>true
);
$this->session->set_userdata($data);
redirect('site/members_area');

}
#5

[eluser]Kentus[/eluser]
i discover that my problems is in this code:

&lt;?php
$user=$this->session->userdata('username');
echo $user;?&gt;
//$username=$this->session->userdata('username');

<div id="mainContent">

<div id="userPanel">
<h3>Account Details</h3>
Wellcome: &lt;?php $user?&gt;
</div> &lt;!-- se inchide userPanel--&gt;

</div>&lt;!-- se inchide mainContent--&gt;
#6

[eluser]Kentus[/eluser]
lol..i was losses the echoSmile)
#7

[eluser]Unknown[/eluser]
it would be great to see updated tutorials on the codeigniter site although im sure at this point people have asked questions regarding these types of errors using the tutorials posted




Theme © iAndrew 2016 - Forum software by © MyBB