Welcome Guest, Not a member yet? Register   Sign In
A PHP Error was encountered - Message: Undefined index: title
#1

Hello Guys, could someone give a Light please, what i am doing wrong here?

Thanks in Advance!


This is my Post Controller:

Code:
    // LOAD POST INDIVIDUALLY
    public function view ($slug = NULL)
    {
        //******* THE FUNCTIONS MUST BE LOADED IN EVERY METHOD *******//
        // Load the Function php echo base_url();
        $this->load->helper('url');
        // Loading a Model Locally
        $this->load->model('Post_model');
        //******* THE FUNCTIONS MUST BE LOADED IN EVERY METHOD *******//
     
        
         $data['post'] = $this->Post_model->get_posts($slug);

        if(empty($data['post']))
        {
             show_404();
        }

        $data['title'] = $data['post']['title'];                
        
        $this->load->view('templates/header');
        $this->load->view('posts/view', $data);
        $this->load->view('templates/footer');

    }


and this the view file:

Code:
<h2><?php echo $post['posts_title']; ?></h2>

<small class="post-date">Posted on:
    <?php echo $post['posts_date_insertion']; ?>
</small><br>

<div class="post-body">
    <?php echo $post['posts_body']; ?>
</div>

and this is the error message on the browser:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: title
Filename: controllers/Posts.php
Line Number: 59
Backtrace:
File: C:\xampp\htdocs\dogs\application\controllers\Posts.php
Line: 59
Function: _error_handler
File: C:\xampp\htdocs\dogs\index.php
Line: 315
Function: require_once
Reply


Messages In This Thread
A PHP Error was encountered - Message: Undefined index: title - by Porto - 02-18-2019, 07:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB