codeigniter error but works fine on my local server - codeigniter

Hello all im working on a project but when i upload my project i got a error you can see here
http://rapcom.dk/profil/index/KoS
but i think im doing it work cause it works on my local PC :S, here is my controller
function index()
{
$this->load->model('profil_model');
$data['query'] = $this->profil_model->vis_profil($this->uri->segment(3));
//Henter lib profilwall så man kan vise wall beskeder i profilen
$this->load->library('profilewall');
$data['queryWall'] = $this->profilewall->wallShow();
$this->template->write_view('content', 'profil_view', $data);
$this->template->render();
}
And my library called profileWall.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Profilewall
{
private $CI;
public function __construct()
{
$this->CI =& get_instance();
}
public function wallShow()
{
$this->CI->load->model('profil_model');
return $this->CI->profil_model->wallGet($this->CI->uri->segment(3));
}
}
do you know what can be wrong? and im 100% sure it is uploaded du the server

This may have to do with how you are naming the actual file. Could you try naming the file profilewall.php rather than profileWall.php and see if that works.
For the most part you should be mindful of case issues, especially with CodeIgniter. Generally the rule of thumb is to use lowercase characters in filenames, models, etc.

Related

localhost is currently unable to handle this request. codeigniter problem

I have this error when i am trying to access a website from wamp, it is done in codeigniter.
Error:
localhost is currently unable to handle this request. HTTP ERROR 500
homeindex controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class HomeIndex extends CI_Controller {
public function __construct(){
parent:: __construct();
$this->load->helper('html');
$this->load->helper('form','url','file');
$this->load->library('session','upload');
}
public function index()
{
//$this->load->view('coming_soon');
$this->load->view('homeIndex');
}
}
route
$route['default_controller'] = 'HomeIndex';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I am able to access other website which are not done using any frameworks.
This website is done using codeigniter. I am not able to access the website.
Can anyone tell me what is the problem?
Multiple loads with one call are done using an array:
$this->load->helper(array('form','url','file'));
$this->load->library(array('session','upload'));
https://www.codeigniter.com/user_guide/libraries/loader.html#CI_Loader::helper
if that doesn't work turn on error reporting (switch to development mode in index.php) and see what the actual error is. 500 error can be many things...

Codeigniter(HMVC) core classes is not loaded in pre_contoller hook

I have downloaded the ci-hmvc-master and setup it.
Now in that I have created a one hook at pre_controller hook point.
In that hook, I have created one function that print the current class and method.
my code looks like this:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Authentication{
protected $CI;
public function __construct() {
$this->CI = & get_instance();
}
public function is_loggedin(){
$class = $this->CI->router->fetch_class();
echo $class;
}
}
This code is working fine. I got the class name.
Now my issue is that when I use this same code in HMVC which is created from normal MVC (replacing some of the folders and files) then I got the error like:
Call to a member function fetch_class() on null
Means The pre_controller hook executes before the super object has been fully constructed, so get_instance() can't work.
So, why it is working in HMVC extension which I have downloaded and why it is
not working in simple HMVC which is created from MVC.
Is there any configuration is missing?

Codeigniter: Unable to locate the specified class: Exceptions.php

Here's my controller:
$html = $this->load->view('print_po', $po, TRUE);
$this->load->library('pdf');
$pdf = $this->pdf->load();
Now I've tried and comment each line and the one that shows the error is:
$pdf = $this->pdf->load();
Here's my library class in application/libraries:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class pdf {
function pdf()
{
$CI = & get_instance();
log_message('Debug', 'mPDF class is loaded.');
}
function load($param=NULL)
{
include_once APPPATH.'/third_party/mpdf/mpdf.php';
if ($params == NULL)
{
$param = '"en-GB-x","A4","","",10,10,10,10,6,3';
}
return new mPDF($param);
}
}
The error comes only after moving the code from one server to another(the error happens on a CentOS server which I bet is case sensitive). My question here would be: what should I modify so codeIgniter loads Exceptions.php normally?
First, remove the forward-slash at the first of /third_party phrase:
include_once APPPATH.'third_party/mpdf/mpdf.php';
CodeIgniter defines APPPATH constant with a trailing slash. Take a look at index.php:
define('APPPATH', $application_folder.'/');
Second, make sure that the file/folder names are as the same as you have wrote. It's better to keep them all lowercase. Here is a related topic.
Update:
The class name should be Capitalized. In this case change the pdf to Pdf:
class Pdf {
// ...
}
From CI Documentation:
Naming Conventions:
File names must be capitalized. For example: Myclass.php
Class declarations must be capitalized. For example: class Myclass
Class names and file names must match.

How to integrate codeigniter and PHPExcel?

always display an error message on my browser:
An Error Was Encountered
Non-existent class: IOFactory
all classes PHPExcel, i extract on library.
Here it is my controller code
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Report extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('form','url'));
}
public function index()
{
$this->load->library('phpexcel');
$this->load->library('PHPExcel/IOFactory.php');
$objPHPexcel = PHPExcel_IOFactory::load('tandaterima.xlsx');
$objWorksheet = $objPHPexcel->getActiveSheet();
//Daftar barang (4item)
$objWorksheet->getCell('B16')->setValue('UTP');
$objWorksheet->getCell('B17')->setValue('Cross');
$objWorksheet->getCell('B18')->setValue('');
$objWorksheet->getCell('B19')->setValue('');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'Excel5');
$objWriter->save('write5.xls');
}
}
please help me.
Follow the instruction here
https://github.com/EllisLab/CodeIgniter/wiki/PHPExcel
Please remember to remove the PHPExcel_ part in the class name in IOFactory.php. And change the construct function from private to public
ensure that u save PHPExcel/IOFactory.php inside libraries folder and load it as $this->load->library('PHPExcel/iofactory');
You can replace this line
$objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'Excel5');
by this line
IOFactory::createWriter($objPHPexcel, 'Excel5');
First you need to place your PHPExcel folder inside thirdparty folder. Then create class file in the library folder. There you need to include thirdparty/PHPExcel file folder and extend the class. After that you can use it in your controller.
And in some Linux Server, you have to care about case.
$this->load->library('PHPExcel');
$this->load->library('PHPExcel/IOFactory');
Codeiginiter 3 supports Composer to use PHPExcel:
In application/config/config.php, set $config['composer_autoload'] to TRUE.
Then you can use Composer to install PHPExcel in Codeiginiter :
composer require phpoffice/phpexcel
Further, You could try PHPExcel Helper to easier handle PHPExcel:
composer require yidas/phpexcel-helper
https://github.com/yidas/phpexcel-helper

Codeigniter 2.0 Can not extend core library

not sure what is the problem? My class that is in Application/core folder, and here it is:
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class MY_Image_lib extends CI_Image_lib {
public function __construct() {
parent::__construct();
}
function tesit($msg) {
log_message('error', $msg);
}
}
I get this error :
Fatal error: Call to undefined method CI_Image_lib::testit()
when I call it like this : $this->image_lib->testit('not working');
What I am missing, this is so strange.
Only the following classes are core classes all others should be extended in library folder.
http://ellislab.com/codeigniter/user-guide/general/core_classes.html
Benchmark
Config
Controller
Exceptions
Hooks
Input
Language
Loader
Log
Output
Router
URI
Utf8
Move your class to the application/library folder and it will override the one in the system folder when you call it.

Resources