Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:17:13+00:00 2026-06-03T21:17:13+00:00

I have the following code written, <?php require_once products.php; $test = new Products; $array

  • 0

I have the following code written,

<?php 
require_once "products.php";
    $test = new Products;

    $array = array(1,2,3,4,5,6,6,7,8,9,10);     
    $start = 4;
    $limit = 9;
    $value =  $test -> limit($array, $start, $limit);
    echo $value;
?>

When I run it, its giving me an error:

Fatal error: Class ‘MX_Controller’ not found in
C:\xampp\htdocs\pro\application\modules\products\controllers\products.php
on line 10

Now there is no reason it should not find the class as its there.

<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Ahmed
 * Date: 4/2/12
 * Time: 9:55 PM
 * To change this template use File | Settings | File Templates.
 */
class Products extends MX_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->library('pagination');
        $this->load->model('products_model');
        $this->load->helper(array('form', 'url', 'html'));
        $this->load->library(array('session', 'upload', 'parser'));

    }

    public function home()
    {
        $this->load->view('products/home');
    }

    public function pre_search()
    {
        redirect('products/search/' . $this->input->post('keyword'));
    }

    public function limit($array, $start, $limit)
    {
        $result = array();
        for($i = 0, $j = $start; ($j < $start + $limit) && ($j < count($array)); $j++, $i++)
            $result[$i] = $array[$j];
        return $result;
    }

    public function search($keyword)
    {
        $products = $this->products_model->search($keyword);
        $data['zerorows'] = empty($products);
        if(!empty($products)){
            $config['cur_tag_open'] = '<span class="current">';
            $config['cur_tag_close'] = '</span>';
            $config['num_tag_open'] = '<span class="page larger">';
            $config['num_tag_close'] = '</span>';
            $config['base_url'] = base_url() . "products/search/" . $keyword;
            $config['total_rows'] = count($products);
            $config['per_page'] = PRODUCT_PERPAGE;
            $config['uri_segment'] = 4;
            $this->pagination->initialize($config);
            $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
            $products = $this->limit($products, $page, PRODUCT_PERPAGE);
            $data['links'] = $this->pagination->create_links();
        }
        $data['products'] = $products;
        $this->load->view('products/index', $data);
    }

    public function makeslist()
    {
        $makes = $this->products_model->getmakes();
        $data['makes'] = $makes;
        $this->load->view('products/makes', $data);
    }
    public function pricelist()
    {
        $this->load->view('products/prices');
    }


    public function make($make)
    {
        $products = $this->products_model->getlistby_make($make);
        $data['zerorows'] = empty($products);
        if(!empty($products)){
        $config['cur_tag_open'] = '<span class="current">';
        $config['cur_tag_close'] = '</span>';
        $config['num_tag_open'] = '<span class="page larger">';
        $config['num_tag_close'] = '</span>';
        $config['base_url'] = base_url() . "products/make/" . $make;
        $config['total_rows'] = count($products);
        $config['per_page'] = PRODUCT_PERPAGE;
        $config['uri_segment'] = 4;
        $this->pagination->initialize($config);
        $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
        $products = $this->limit($products, $page, PRODUCT_PERPAGE);
            $data['links'] = $this->pagination->create_links();
        }
        $data['products'] = $products;

        $this->load->view('products/index', $data);
    }

    public function price($lower, $upper)
    {
        $products = $this->products_model->getlistby_price($lower, $upper);
        $data['zerorows'] = empty($products);
        if(!empty($products)){
        $config['cur_tag_open'] = '<span class="current">';
        $config['cur_tag_close'] = '</span>';
        $config['num_tag_open'] = '<span class="page larger">';
        $config['num_tag_close'] = '</span>';
        $config['base_url'] = base_url() . "products/price/" . $lower . "/" . $upper;
        $config['total_rows'] = count($products);
        $config['per_page'] = PRODUCT_PERPAGE;
        $config['uri_segment'] = 5;
        $this->pagination->initialize($config);
        $page = ($this->uri->segment(5)) ? $this->uri->segment(5) : 0;
        $products = $this->limit($products, $page, PRODUCT_PERPAGE);
            $data['links'] = $this->pagination->create_links();
        }
        $data['products'] = $products;

        $this->load->view('products/index', $data);
    }


    public function index()
    {
        $products = $this->products_model->getlist(PRODUCT_HOMEPAGE, FALSE);
        $data['zerorows'] = empty($products);
        if(!empty($products)){
        $config['cur_tag_open'] = '<span class="current">';
        $config['cur_tag_close'] = '</span>';
        $config['num_tag_open'] = '<span class="page larger">';
        $config['num_tag_close'] = '</span>';
        $config['base_url'] = base_url() . "products/index";
        $config['total_rows'] = count($products);
        $config['per_page'] = PRODUCT_HOMEPAGE;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
        $products = $this->limit($products, $page, PRODUCT_HOMEPAGE);
        $data['links'] = $this->pagination->create_links();
        }
        $data['products'] = $products;
        $this->load->view('products/index', $data);

    }

    public function show($id)
    {
        $product = $this->products_model->getproduct_by_id($id);
        if(!empty($product))
        {
            $product[0]->reviews = modules::run('reviews/index', $id);
            $product[0]->reviewform = modules::run('reviews/addnew', $id);
            $this->load->view('products/show', $product[0]);
        }
        else
            show_error("Product with ID: " . $id . " not found in database.");
    }

    public function create()
    {
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->form_validation->set_rules('make', 'Make', 'required');
        $this->form_validation->set_rules('model_no', 'Model Number', 'required');
        $this->form_validation->set_rules('description', 'Description', 'required');
        $this->form_validation->set_rules('price', 'Price', 'required');
        $this->form_validation->set_rules('image_url', 'Image', 'callback__do_upload');
        if($this->form_validation->run($this) === FALSE)
        {
            $this->session->set_flashdata("message", validation_errors());
            $this->load->view('products/new');
        }
        else
        {
            $post = array();
            $post['seller_id'] = $this->input->post('seller_id');
            $post['make'] = $this->input->post('make');
            $post['model_no'] = $this->input->post('model_no');
            $post['description'] = $this->input->post('description');
            $post['price'] = $this->input->post('price');
            $post['image_url'] = $this->input->post('image_url');
            $post['thumb_url'] = $this->input->post('thumb_url');
            $this->products_model->save($post);
            $this->load->view('products/done');
        }
    }

    public function _do_upload()
    {
        $field_name = 'image_url';
        if ( ! $this->upload->do_upload($field_name))
        {
            $this->form_validation->set_message('_do_upload', $this->upload->display_errors());
            return FALSE;
        }
        else
        {
            $filedata = $this->upload->data();
            $this->load->library('image_moo');
            if($filedata['image_height'] > IMAGE_HEIGHT || $filedata['image_width'] > IMAGE_WIDTH)
            {
                $this->image_moo->load($filedata['full_path']);
                $this->image_moo->resize(IMAGE_WIDTH, IMAGE_HEIGHT);
                $this->image_moo->save($filedata['full_path']);
            }
            $this->image_moo->load($filedata['full_path']);
            $this->image_moo->resize(THUMB_WIDTH, THUMB_HEIGHT, FALSE);
            $this->image_moo->save_pa("", "_thumb", TRUE);
            $_POST['image_url'] =  UPLOAD_PATH . $filedata['file_name'];
            $_POST['thumb_url'] =  UPLOAD_PATH . $filedata['raw_name'] . "_thumb" . $filedata['file_ext'];
            return TRUE;
        }
    }

    public function addnew()
    {
        $isloggedin = $this->session->userdata('isloggedin');
        if($isloggedin)
        {
            $data['seller_id'] = $this->session->userdata('userid');
            $this->load->view('products/new', $data);
        }
        else
        {
            $this->session->set_flashdata("message", "You must be logged in, to list a product for selling.");
            redirect("/products");
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:17:15+00:00Added an answer on June 3, 2026 at 9:17 pm
    class Products extends MX_Controller
    

    means, that your (new) class ‘Products’ extends the (already) existing class ‘MX_Controller’. So this the line of definition for the Products-class, not the MX_Controller. Are you including the MX/Controller.php-file?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following example code <?php `echo test > /tmp/test.txt`; $f=fopen(/tmp/test.txt,w+); `rm /tmp/test.txt`;
I have written following PHP code: $input=menu=1&type=0&; print $input.<hr>.ereg_replace('/&/', ':::', $input); After running above
I have written the following code to fadeout a DIV, then load a new
I have the following php code: echo <div style='float:left;'>; echo <table>; echo <tr>; echo
I am learning file handling in php. I have written the following code to
I'm using some not optimal code written by me... :-| I have following code:
I have written following code to attach gesture recogniser to multiple imageviews. [imageview1 setUserInteractionEnabled:YES];
I am trying my hands on WPF MVVM. I have written following code in
In physics library written in C# I have the following code: (in ContactManager.cs) public
I have written the following code in SWI-Prolog: :- dynamic state_a/1 . :- dynamic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.