Please help me.. i'm about to launching a website, i build this website with codeigniter3. I've made configuration changes such as base_url, database, etc. But it show me an error like this :
Message: Undefined property: Home::$home Filename: controllers/Home.php Line Number: 18 Backtrace: File: /home/u8460348/public_html/application/controllers/Home.php Line: 18 Function: _error_handler File: /home/u8460348/public_html/index.php Line: 294 Function: require_once ```
Message: Call to a member function select() on null Filename: /home/u8460348/public_html/application/controllers/Home.php Line Number: 18 Backtrace: File: /home/u8460348/public_html/index.php Line: 294 Function: require_once ```
So, here is my controller :
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Home extends My_Controller { public function index($page = null) { $data['title'] = 'Home | Omid Health Style'; $data['content'] = $this->home->select( [ 'product.id', 'product.slug', 'product.title AS product_title', 'product.description', 'product.image', 'product.price', 'product.is_available', 'product.weight', 'category.title AS category_title', 'category.slug AS category_slug' ] ) ->join('category') ->where('product.is_available', 1) ->paginate($page) ->get(); $data['total_rows'] = $this->home->where('product.is_available', 1)->count(); $this->home->table = 'blog'; $data['blogs'] = $this->home->select( [ 'blog.id', 'blog.slug', 'blog.title AS blog_title', 'blog.description', 'blog.content', 'blog.image', 'blog_category.title AS blog_category_title', 'blog_category.slug AS blog_category_slug' ] ) ->join('blog_category') ->paginate($page) ->get(); $data['total_rows'] = $this->home->count(); $data['page'] = 'pages/home/index'; $this->view($data); } }
Here is my Home_model.php :
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Home_model extends MY_Model { public $table = 'product'; protected $perPage = 8; } /* End of file Home_model.php */
And here is in my core folder, because i made a custom configuration like this :
<?php defined('BASEPATH') or exit('No direct script access allowed'); class My_Controller extends CI_Controller { public function __construct() { parent::__construct(); $model = strtolower(get_class($this)); if (file_exists(APPPATH . 'models/' . $model . '_model.php')) { $this->load->model($model . '_model', $model, true); } } // Load view with Default Layouts public function view($data) { $this->load->view('layouts/app', $data); } }
I don't know what to do because if i'm running the program in my local it's totally fine and work.
https://stackoverflow.com/questions/65819958/codeigniter-3-a-php-error-was-encountered-severity-notice-message-undefine January 21, 2021 at 09:27AM
没有评论:
发表评论