<?php
session_start();
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class View_job extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('Userdb', '', TRUE);
$this->load->model('Locationdb');
$this->load->model('All_functiondb');
$this->load->library('form_validation');
}
}
///
A PHP Error was encountered Severity: Notice
Message: Undefined property: Indexpg::$session
Filename: php_include/authenticate.php
Line Number: 3
Fatal error: Call to a member function userdata() on null in
C:\xampp\htdocs\CodeIgniter-job-site-master\hindusthanjobs\application_candidate_6423\php_include\authenticate.php
on line 3
define session after tis line
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
first thing is that check is session library is loded in controller.
public function __construct()
{
parent::__construct();
$this->load->library('session');
}
Related
I know this quention might seems duplicated, but i already tried those suggestions/advice but still couldn't solve this:
environment :
$autoload['libraries'] = array('email', 'session', 'database', 'form_validation');
controller :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->model('Auth_model', 'Auth');
}
private function _login()
{
$email = $this->input->post('email');
$password = $this->input->post('password');
$user = $this->model->Auth->getUser();
Model :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth_model extends CI_Model
{
public function getUser()
{
$email = $this->input->post('email');
// var_dump($email);die;
return $this->db->get_where('t_user', ['email' => $email])->row_array();
}
}
I Still got this error :
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Auth::$model
Filename: controllers/Auth.php
Line Number: 38
Change
$user = $this->model->Auth->getUser();
into
$user = $this->Auth->getUser();
try this into the class you will use
Type $ this-> library -> (" library you want "). I hope it helps.
I'm trying to extend CI_Loader class to override _ci_load_library(), but I'm receiving:
Fatal error: Class 'CI_Loader' not found in C:\Users\X\workspace\ci-app\application\core\MY_Loader.php on line 4
A PHP Error was encountered
Severity: Error
Message: Class 'CI_Loader' not found
Filename: core/MY_Loader.php
Line Number: 4
Backtrace:
The class MY_Loader is located in application/core/MY_Loader.php, and it's like this:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Loader extends CI_Loader
{
public function __construct()
{
parent::__construct();
}
protected function _ci_load_library($class, $params = NULL, $object_name = NULL)
{
// ...
}
}
I'm using the latest version of CodeIgniter: 3.1.9
Try Adding below line above declaration of class MY_Loader
require APPPATH."../system/core/Loader.php";
I am trying to use session in my project. It works on localhost but not on web server. I read some articles about that in stackoverflow and ellislab, but it didn't work for my project. Probably problem is about creating ancillary classes.
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Memberlogin extends CI_Controller {
//protected $CI;
function __construct()
{
$CI =& get_instance();
parent::__construct();
$CI->load->library('session');
//$this->load->library('form_validation');
//$this->load->helper(array('form', 'url'));
$CI->load->helper('date');
$CI->load->helper('ip_address');
$CI->load->model('Sql_model');
}
Now errors are :
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Line Number: 14
and
A PHP Error was encountered
Severity: Error
Message: Call to a member function library() on a non-object
Line Number: 14
Try this code,
function __construct()
{
parent::__construct();
$this->load->library('session');
$this->load->helper('date');
$this->load->helper('ip_address');
$this->load->model('Sql_model');
}
If class is in controllers directory, you can directly get the CI instance by extending the CI_Controller and use $this.
Than, try without calling get_instance() function. Just like docs says:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Memberlogin extends CI_Controller {
//protected $CI;
function __construct()
{
parent::__construct();
$this->load->library('session');
//$this->load->library('form_validation');
//$this->load->helper(array('form', 'url'));
$this->load->helper('date');
$this->load->helper('ip_address');
$this->load->model('Sql_model');
}
This will make you crazy. but it works.
In autoload.php
$autoload['libraries'] = array('database', 'session');
$autoload['helper'] = array('url','date','ip_address');
and load model in __constructor
public function __construct()
{
parent::__construct();
$this->load->model('Sql_model');
}
I'm working on a calendar planning provided by [easyappointments][1] but now I'm stuck on this error by yesterday. In the main page users.php I've added the following:
<?php
require_once("application/models/impostazioni_model.php");
$this->load->model('impostazioni_model');
$this->impostazioni_model->load_colours();
?>
the require_once find correctly the file impostazioni_model.php but when I enter in the page users.php I see this error:
Fatal error: Call to a member function load_colours() on a non-object
on this line: $this->impostazioni_model->load_colours();
in the class impostazioni_model.php I've this content:
<?php if ( ! defined('BASEPATH')) exit('Direct execution not allowed.');
class Impostazioni_Model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function load_colours()
{
echo "print";
}
}
?>
I've followed the codeigniter documentation, in particular the class model must be in capital letter so I don't know what I'm wrong. Someone could help me out?
In Controller
Path - application/controllers
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Admin extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('impostazioni_model'); //this will show "Print" word on browser.
}
function index() {
$this->impostazioni_model->load_colours();
}
}
In Model
Path - application/model
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Impostazioni_model extends CI_Model {
function __construct() {
parent::__construct();
}
function load_colours() {
echo "print";
}
}
Hi all I am having an error and I just can't see why codeigniter is throwing the error:
controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Management extends CI_Controller {
public function index(){
//calls login page view
$this->managementView();
}
public function managementView(){
//loads course page view
$users['users'] = $this->management_model->getInfo();
$this->load->view("header");
$this->load->view("users", $users);
$this->load->view("footer");
}
}
Model:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Management_model extends CI_Model{
function getInfo(){
$query = $this->db->get("users");
$result = $query->result_array();
return $result;
}
}
I am receiving the following error, I just can't seem to see what the hell I'm doing wrong - I'm new to web stuff so don't know what these errors indicate:
Fatal error: Call to a member function getInfo() on a non-object
also see this:
Severity: Notice
Message: Undefined property: Management::$management_model
Filename: controllers/management.php
Line Number: 12
I can't see the issue? - If anyone could point it out would be much appreciated.
you need to load the model before calling any function from the model.
for eg:
$this->load->model('management_model');
$users['users'] = $this->management_model->getInfo();
or you can load it via the constructor.
function __construct() {
parent::__construct();
$this->load->model('management_model');
}
}
the notice you are getting is clearly telling about the undefined property management model
you can see more about this here
You dont appear to ever set the management_model property in your controller.
I would expect to see something like this somewhere in your controller:
$this->management_model = new Management_model();
Initially you can load the model like this
$this->load->model('management_model');
then only u can use the object to call function
you need some more clarity Click
use
$this->load->model('management_model');
before
$users['users'] = $this->management_model->getInfo();