I want to use pagination in my index page. So I used like following code in my project
class Transactions extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model(array("Transaction"));
}
public function index()
{
$cond = array();
if($_POST){
$cond = $this->input->post();
}
// load Pagination library
$this->load->library('pagination');
It's work fine in my localhost, but when I upload this in live server, here show the following error..
An Error Was Encountered
Unable to load the requested class: Pagination
enter image description here
php v7.2
codeigniter v3.1.11
Please anyone help me how to solve this problem.
Related
Hi I followed this tutorial: https://book.cakephp.org/3/en/tutorials-and-examples/blog/part-two.html and having problem when tried to access the links: localhost/myprojectname/articles/index and localhost/myprojectname/articles/view/1
This is the screenshot:
Error:Missing Controller
I am using XAMPP and Chrome browser. The article model, articles controller and article view are created as written in the tutorial. But when I was trying to access the link at localhost/myprojectname/articles/index, there is missing controller error as shown in the screenshot above.
However, after insert <?php in the top of the articles controller and article model file, still showing same missing controller error as this screenshot: Error: Missing Controller 2
Copy and paste this to your AppController:
<?php
namespace App\Controller;
class ArticlesController extends AppController
{
public function index()
{
$this->set('articles', $this->Articles->find('all'));
}
public function view($id = null)
{
$article = $this->Articles->get($id);
$this->set(compact('article'));
}
}
I had a working project uploaded to server 2 week before. It was working fine until now. Below is code for model awsmodel.php
class Awsmodel extends MY_Model {
function __construct()
{
}
// some other functions
}
MY_Model again extends to CI_model.
class MY_Model extends CI_Model {
// required functions
}
From controller pages.php I am calling the function like below.
class Pages extends MY_Controller {
public function index()
{
$data = $this->allCommonMenu();
$this->load->model('Awsmodel');
$data['featured'] = $this->Awsmodel->featuredProp();
$this->load->view('home_pz',$data);
}
}
The above code suddenly stooped working today. After some test and tries, I got to know that when I comment below 2 lines from controller function then The page loads.
$this->load->model('Awsmodel');
$data['featured'] = $this->Awsmodel->featuredProp();
I have changed environment variable to 'development' and tested but still no error message shows. In firefox its showing a blank page, where as in chrome it shows 500 server error. The same code was working since 2 weeks. Don't know why its not working now. If anyone can help me out ?
I am using CI version 2.1.4
If you using CI 3.0 please load model like this
class Pages extends MY_Controller {
public function index()
{
$data = $this->allCommonMenu();
$this->load->model('awsmodel'); //as your model filename: awsmodel.php
$data['featured'] = $this->Awsmodel->featuredProp();
//$data['featured'] = $this->awsmodel->featuredProp();// for CI version 2.1.4 –
$this->load->view('home_pz',$data);
}
}
In the codeigniter I get this message :
Unable to load the requested file: home.php
controller :
cp/
Login
views :
cp/
home.blade.php
class Login extends BaseController {
public function __construct(){
parent::__construct();
}
function index()
{
$this->load->view('home','');
}
}
or :
class Login extends BaseController {
public function __construct(){
parent::__construct();
}
function index()
{
$this->load->view('cp/home','');
}
}
http://www.vitrinsaz1.ir/Mobile/Vitrinsaz/Pannel/cp/login
Hi when loading views remember to make sure that you name it correctly like in your instance you could do the following:
function index()
{
$this->load->view('home_blade');
}
remove the period in the name of the file and replace it with a underscore and then make sure the view file itself is named home_blade.php
Hey there I was also encountered by this error and my error was solved by rechecking the parent folder name try replacing cp.
$this->load->view('cp/home');
with this
$this->load->view('Cp/home');
I think this could be the issue..
My code was working fine on localhost but on server it wasn't loading the view. my error was solved by this.
If the code is correct and you still experiencing that error, change folder permissions :
chmod -R 777 "your folder"
I had a similar problem and that solved it.
I have some issues with Routes in CI. also new with this framework. I want to ask you guys, (I have read similar example with my problem but it doesn't work for me).
(the link)
Codeigniter routing issues
every time I want to link another page in main page. CI said:![error routes][1]
An Error Was Encountered
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.
when i access this url in my browser: /test, i get the error routes.
here is a sample of my routes.php:
$route['default_controller'] = "frontline";
$route['404_override'] = 'error404';
$route['test'] = 'frontline/test';
and this my controller:
class Frontline extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('index.php');
}
public function test(){
echo "test";
}
}
When using Codeigniter to load the database, I am getting the following error message in a simple file where I load the database:
An Error Was Encountered
Unable to load the requested class: database
The controller for this code is called db.php, and the code for it is as follows:
<?php
class Db extends MY_Controller {
function __construct() {
parent::__construct();
$this->load->library('database');
}
public function index() {}
}
I do not have the database loaded in to autoload.php. I also know that I have the correct database information in my config.php file. My CodeIgniter application is in a subdomain if that might cause any problems.
Any ideas on what could be causing the problem? Thanks.
Use $this->load->database();
Instead of $this->load->library('database');