Unable to load the requested file in Codeigniter - php

Everything is working fine on my Localhost(Xampp) but when i upload the same code on Server(cPanel) then it is giving me error Unable to Load the Requested File
Controller:
class Industries extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function view_industry($id) {
$data['view_industry'] = $this->Industry_model->view_industry($id);
$data['main_view'] = "Industries/view_industry";
$this->load->view('templates/main', $data);
}
}
Route:
$route['view_industry'] = "Industries/view_industry";
View :
What could be the reason??? because the same code is working absolutely fine on LOCALHOST.

Actually the CASE was the issue.
For example Industries != industries
Thanks Guys.

Related

Why does my PHP error controller work with PHP 5, but not PHP 7?

I'm migrating my project from PHP 5 to PHP 7.3, I have made the changes for the decrypted function with alternative functions. But am facing issue with the one controller file.
The same code works for PHP5 version, But when am trying to execute same code for PHP 7 it doesn't give any error even there is no error got added in errorLog file. Could you please help me out this.
I'm uploading my 'error.php' Controller file.
<?php
class Error extends CI_Controller {
private $controller = "error";
public function __construct() {
parent::__construct();
if ($this->phpsession->get('USERID')) {
$headerContent['controller'] = $this->controller;
$this->load->view('xome/header', $headerContent);
} else {
header("Location:" . ASITEURL . "/login/");
}
}
public function index() {
$this->load->view('x-404');
$this->load->view('xome/footer');
}
public function permission() {
$this->load->view('x-permission');
$this->load->view('xome/footer');
}
public function display() {
$this->load->view('x-error');
$this->load->view('xome/footer');
}
}
?>
When I hit the URL it should load the view page but unable to load any view file.
http://localhost/--project folder name--/error/permission
Even I checked there is no syntax error in the controller as well as any view file.
As of PHP7, Error is a reserved class name: http://php.net/manual/en/class.error.php.
Change it to something else:
class MyError extends CI_Controller
{
// ....
}

Loading model prints query

I'm trying to setup a codeigniter-page which already works perfect on another sever.
I have changed the database.php file such that it connects to the local database instead. Else, nothing else is changed.
But when i load the page it just print out the queries from my model.
I believed I'm well connected to the database I experience other errors if there is no connection to the DB.
I believe it is a configuration error as nothing else is changed on the page (and it is working fine on another server).
There is used CodeIgniter 2.1.3
Does any know this error?
UPDATE: Here is snips of my controller (I call index-page). The inherited class (MY_Controller) is empty
class Page extends CI_Controller {
public function __construct() {
// session_start();
parent::__construct();
$this->load->model('Page_model');
}
public function index() {
// $this->show(1);
}
And the page_model which i load:
<?
class Page_model extends CI_Model {
function __construct(){
parent::__construct();
}
function get_page($id){
$this->db->where('id', $id);
$query = $this->db->get('gahk_page');
return $query->result();
}
function update_by_id($id, $data){
$this->db->where('id', $id);
$this->db->update('gahk_page', $data);
}
}
?>
Your server may not be supporting PHP "short_open_tag", so the actual code is displayed in model.
Enable "short_open_tag" in php.ini or use <?php ?> tags in models.

Codeigniter routing strange 404 error

I have a problem with codeigniter routing.
I can't understand at all, what's wrong.
I have a rule in my routes.php file:
$route['multimedia/(:any:)'] = 'multimedia/$1';
$route['multimedia'] = 'multimedia/index';
So, if I go to http://mywebsite.com/multimedia - all is works well , but if I go to http://mywebsite.com/multimedia/hello I get 404 Error.
This is a part of my multimedia controller:
<?php
class Multimedia extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('multimedia_model');
$this->load->helper('language');
$this->load->helper('form');
}
public function index(){
//............This works
}
public function hello()
{
//..........This not works
}
}
The most strange thing to me, that I have another same rule in routes.php file,
$route['popup/(:any)'] = 'popup/$1';
$route['popup'] = 'popup/index';
which is works well when I go to mywebsite.com/popup and mywebsite.com/popup/hello
Anybody, please, help me, what's wrong??
$route['popup'] = 'popup/index';
$route['popup/(:any)'] = 'popup/$1';
(:any) specification should only be called only after all other constraints.
Try this...

"Unable to load the requested file"

Using CodeIgniter 2.0.3 on XAMPP 1.7.7 I have code where I get the error as: Unable to load the requested file: home.php
The home.php code as follows stored in ./ci2/application/controllers:
class Home extends CI_Controller {
function Home()
{
parent::__construct();
}
function index()
{
$this->load->view('home');
}
While using it just notice:
controller's name is home.php
File named home.php must be present in ci/views
Incase file extention in view folder is not php eg like its html.
then load it using : $this->load->view('home.html');
the function u need to call from outside must be public So make it:
public function index() {... }
as u are calling the constructor for the class Home. Call it like:
class Home extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('home');
}
Now it will work !
Your call to $this->load->view('home'); will be looking for home.php in /ci2/application/views/. That's the file it can't find.
I'm assuming you're calling http://myapp/index.php/home/ - that means it'll automatically call the index() method.
class Home extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('home');
}
}
Please check the name of the file you have created in application/views/, because otherwise the code is correct.

Fatal error: Call to undefined function validation_errors() in

Here is the code:
class CCI extends Controller {
function CCI()
{
parent::Controller();
}
function index()
{
$this->load->helper('url');
$this->load->view('Users/login');
}
function test()
{
echo "Testing Data";
}
}
The page was loading fine until I moved the location of the "login" page inside of the "Users" folder
Well then probably change
$this->load->view('Users/login');
to
$this->load->view('login');
Since you moved the file inside the Users folder you need to adjust paths for that.
You're properly displaying any validation errors within your view using the 'validation_errors' function that's located in the 'form_helper'. Load the 'form_helper' as well and you should be fine.
Add following two lines of code to the controller:
$this->load->helper('form');
$this->load->library('form_validation');

Categories