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');
Related
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.
I have extended CI's baked in form validation, however I'm having issues loading a language files. I have the following code:
class MY_Form_validation extends CI_Form_validation {
public function __construct() {
parent :: __construct();
$this->load->lang('raf');
}
However this throws the error:
Call to a member function lang() on a non-object
Can anyone spot the issue here?
To load language in codeigniter, Syntax is :
$this->lang->load('filename', 'language');
Not:
$this->load->lang();
Try after load Helper file
$this->load->helper('language');
After Hosting Php codeignitor website I Got a Error "Unable to locate the model you have specified: Common_model"
But Its Works in my local server
How I can solve this issue
I already change First letter of the model class name capitalized but no result
my model class
class Common_model extends CI_Model
{
}
and controller is
<?php
class Show extends CI_Controller
{ var $pageLimit = 6;
public function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->model('common/Common_model');
$this->load->helper('url');
$this->load->helper('form');
$this->load->helper('custom');
}
}
If you are are using Codeignitor 3 than make sure you file name also start with capital letter as:
Common_model.php
It's recommended to use your models inside the model folder not model/anyfolder
Codeignitor 3 Change Log User Manual
I hope Your model file structure is like
application
model
common
Common_model.php
File name should be Common_model.php.
Load in Controller should be
$this->load->model('common_model');
I always load it with the name only, this way
$this->load->model('Common_model');
Always the controller is on the same module (if you are using modules)
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.
We are using Code Igniter version 2.2 to develop an application. We have created it locally and it works fine however when uploaded onto the server we get the following error:
An Error Was Encountered
Unable to load the requested file: Abc/xyz.php
(file name changed for question)
Code in controller:
class Abc extends CI_Controller {
public function xyz(){
$this->load->view(__CLASS__."/".__FUNCTION__);
}
When I modify the code to the following the page appears:
class Abc extends CI_Controller {
public function xyz(){
$this->load->view("Abc/xyz");
}
How can I get the above code run using Class & Function?
Thanks for your time & efforts.
Can you use echo __CLASS__."/".__FUNCTION__ to debug this value on server.