I am using Codeignitor code, the code works fine and show output on localhost fine but the same code when run on live server gives an error as:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$data
Filename: controllers/Welcome.php
Line Number: 49
Backtrace:
File: /application/controllers/Welcome.php
Line: 49
Function: _error_handler
The code is as follows
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller
{
public function __construct()
{
parent::__construct();
if (!$this->ion_auth->logged_in() || empty($this->session->name))
{
redirect('/login');
}
$this->load->helper('url');
$this->load->model('BasicModel', 'basic');
$this->load->model('LabelModel', 'label');
}
public function index()
{
//if candidate, go to basic details
if($this->ion_auth->in_group('candidate'))
{
redirect('basic/edit/'.$this->session->basic_id);
}
if($_SESSION['org']==1)
{
//Get MIS count
$this->getMISCount();
}
else
{
//Get Vericraft count without integration
$this->getCount();
}
if($this->ion_auth->in_group('admin'))
{
//Get Client list
$this->getClientList();
}
else if($this->ion_auth->in_group('dev'))
{
$this->getDevData();
}
$this->load->view('welcome_message', $this->data);
}
public function candidate()
{
$this->data['label_data'] = $this->label->view_label();
$query = $this->db->query("SELECT id, CONCAT(CAST(AES_DECRYPT(fname,'".encrypted_key."') AS CHAR) AS fname,' ',CAST(AES_DECRYPT(mname,'".encrypted_key."') AS CHAR) AS mname, ' ',CAST(AES_DECRYPT(sname,'".encrypted_key."') AS CHAR) AS sname) as name,Refno, gender, CAST(AES_DECRYPT(dob,'".encrypted_key."') AS CHAR) AS dob, CAST(AES_DECRYPT(email,'".encrypted_key."') AS CHAR) AS email, CAST(AES_DECRYPT(contact,'".encrypted_key."') AS CHAR) AS contact, CAST(AES_DECRYPT(empid,'".encrypted_key."') AS CHAR) AS empid, CAST(AES_DECRYPT(location,'".encrypted_key."') AS CHAR) AS location, CAST(AES_DECRYPT(report,'".encrypted_key."') AS CHAR) AS report FROM basic WHERE user_id =".$this->session->user_id);
$this->data['show_data'] = $query->result_array();
//to get total document label
$label_query = $this->db->select('id, label')->from('components')->get();
$this->data['labels'] = array_column($label_query->result_array(), 'label');
$query =$this->db->select('COUNT(vlink.id) as num_doc, vlink.file_name, vlink.created_at, vlink.updated_at, vlabel.label')
->from('document_links as vlink')
->join('components as vlabel', 'vlink.comp_id = vlabel.id', 'full outer')
->where('vlink.user_id', $this->session->user_id)
->group_by('vlink.comp_id')
->get();
$this->data['count_data'] = array_column($query->result_array(), 'num_doc', 'label');
$this->session->set_flashdata('message', 'Details updated successfully!');
return redirect($this->agent->referrer());
}
public function logout()
{
$this->ion_auth->logout();
redirect('login/index', 'refresh');
}
public function getMISCount()
{
if($this->ion_auth->in_group('admin'))
{
//MIS Total cases
$this->data['mis_total']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as total FROM ichek_database WHERE ichek_database.Refno NOT LIKE '%test%' AND ichek_database.reasonpending NOT LIKE '%dup%';")->row();
//MIS Pending Cases
$this->data['mis_pending']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as pending FROM ichek_database WHERE ichek_database.Refno NOT LIKE '%test%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate='' OR ichek_database.reportdate=0 OR ichek_database.reportdate IS NULL);")->row();
//MIS Green Cases
$this->data['mis_green']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as green FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno NOT LIKE '%test%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND ichek_database.reportdate!='' AND ichek_database.reportdate!=0 AND ichek_database.reportdate IS NOT NULL AND (ichek_remark.negdedupcolor='' OR ichek_remark.negdedupcolor IS NULL OR ichek_remark.negdedupcolor='Green');")->row();
//MIS Amber Cases
$this->data['mis_amber']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as yellow FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno NOT LIKE '%test%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate!='' AND ichek_database.reportdate!=0 AND ichek_database.reportdate IS NOT NULL) AND ichek_remark.negdedupcolor='Amber';")->row();
//MIS Red Cases
$this->data['mis_red']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as red FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno NOT LIKE '%test%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate!='' AND ichek_database.reportdate!=0 AND ichek_database.reportdate IS NOT NULL) AND ichek_remark.negdedupcolor='Red';")->row();
//MIS Stop Cases
$this->data['mis_stop']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as stop FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno NOT LIKE '%test%' AND ichek_database.reasonpending LIKE '%stop%';")->row();
}
else if($this->ion_auth->in_group('client'))
{
//MIS Total cases
$this->data['mis_total']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as total FROM ichek_database WHERE ichek_database.Refno LIKE '%".$_SESSION['client_code']."%' AND ichek_database.reasonpending NOT LIKE '%dup%';")->row();
//MIS Pending Cases
$this->data['mis_pending']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as pending FROM ichek_database WHERE ichek_database.Refno LIKE '%".$_SESSION['client_code']."%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate='' OR ichek_database.reportdate=0 OR ichek_database.reportdate IS NULL);")->row();
//MIS Green Cases
$this->data['mis_green']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as green FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno LIKE '%".substr($_SESSION['client_code'], 0, 4)."%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate!='' AND ichek_database.reportdate!=0 AND ichek_database.reportdate IS NOT NULL) AND (ichek_remark.negdedupcolor='' OR ichek_remark.negdedupcolor IS NULL OR ichek_remark.negdedupcolor='Green');")->row();
//MIS Amber Cases
$this->data['mis_amber']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as yellow FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno LIKE '%".substr($_SESSION['client_code'], 0, 4)."%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate!='' AND ichek_database.reportdate!=0 AND ichek_database.reportdate IS NOT NULL) AND ichek_remark.negdedupcolor='Amber';")->row();
//MIS Red Cases
$this->data['mis_red']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as red FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno LIKE '%".substr($_SESSION['client_code'], 0, 4)."%' AND (ichek_database.reasonpending NOT LIKE '%dup%' AND ichek_database.reasonpending NOT LIKE '%stop%') AND (ichek_database.reportdate!='' AND ichek_database.reportdate!=0 AND ichek_database.reportdate IS NOT NULL) AND ichek_remark.negdedupcolor='Red';")->row();
//MIS Stop Cases
$this->data['mis_stop']=$this->load->database('mis',TRUE)->query("SELECT COUNT(*) as stop FROM ichek_database INNER JOIN ichek_remark ON ichek_database.Refno=ichek_remark.Refno WHERE ichek_database.Refno LIKE '%".substr($_SESSION['client_code'], 0, 4)."%' AND ichek_database.reasonpending LIKE '%stop%';")->row();
}
}
public function getCount()
{
if($this->ion_auth->in_group('admin'))
{
$query=$this->db->query("select count(vbasic.id) as num, vbasic.status from basic as vbasic inner join users on vbasic.user_id=users.id WHERE users.org=".$this->session->org." group by vbasic.status;");
}
else if($this->ion_auth->in_group('client'))
{
$query=$this->db->query("select count(vbasic.id) as num, vbasic.status from basic as vbasic inner join users on vbasic.user_id=users.id where vbasic.Refno like '%".$this->session->client_code."%' and users.org=".$this->session->org." group by vbasic.status;");
}
else if($this->ion_auth->in_group('dev'))
{
$query=$this->db->query("select count(vbasic.id) as num, vbasic.status from basic as vbasic inner join users on vbasic.user_id=users.id WHERE users.org=".$this->session->org." group by vbasic.status;");
}
$this->data['countData'] = array_column($query->result_array(), 'num', 'status');
}
public function getClientList()
{
if($_SESSION['org']==1)
{
$this->data['mis_clients']=$this->load->database('mis',TRUE)->query("SELECT DISTINCT(temp.full_name) as full_name, temp.client FROM temp INNER JOIN ichek_basic ON temp.client=ichek_basic.client INNER JOIN ichek_database ON ichek_basic.Refno=ichek_database.Refno WHERE temp.client NOT LIKE '%test%' AND ichek_database.reasonpending NOT LIKE '%dup%' ORDER BY temp.full_name")->result();
}
else
{
$this->data['clients'] = $this->db->query("SELECT DISTINCT(users.company), users.client_code FROM `users` INNER JOIN users_groups on users.id=users_groups.user_id WHERE users.org=".$this->session->org." AND users_groups.group_id=2 order by users.company asc")->result();
}
}
public function getDevData()
{
$this->data['totalActiveOrg'] = $this->db->query("SELECT COUNT(DISTINCT(org)) as num FROM `users` WHERE org!=0")->row();
$this->data['totalUsers'] = $this->db->query("SELECT COUNT(id) as num FROM users_groups WHERE group_id!=4")->row();
$this->data['totalCases'] = $this->db->query("SELECT COUNT(id) as num FROM basic")->row();
$this->data['totalFilesUploaded'] = $this->db->query("SELECT COUNT(document_links.id) as num FROM `document_links` INNER JOIN users on document_links.user_id=users.id")->row();
$this->data['fileName'] = $this->db->query("SELECT DISTINCT(file_name) FROM `document_links`")->result();
$this->data['organizations']=$this->db->query("SELECT DISTINCT(organization.org_name),organization.id from organization INNER JOIN users on organization.id=users.org WHERE users.org!=0 ORDER BY organization.org_name")->result();
}
}
?>
<?php
$this->load->view('layouts/header.php');
$this->load->view('layouts/navbar.php');
?>
<!-- page content -->
<?PHP
if(!($this->ion_auth->in_group('dev')))
{
?>
<div class="right_col" role="main">
<!--******************** START SESSION SETFLASH MESSAGES *****************************-->
<?php
if($this->session->flashdata('message'))
{
?>
<div class="alert alert-success">
<?php echo $this->session->flashdata('message')?>
</div>
<?php
}
?>
<!--************************* END SESSION SETFLASH MESSAGES ************************-->
<!-- top tiles -->
<?php
$stopcase = $inprocess = $green = $red = $yellow = 0;
if($_SESSION['org']==1)
{
$green= $green+$mis_green->green;
$red= $red+$mis_red->red;
$yellow= $yellow+$mis_amber->yellow;
$stopcase= $stopcase+$mis_stop->stop;
$inprocess= $inprocess+$mis_pending->pending;
}
else
{
foreach($countData as $status => $num)
{
if($status == 'inprocess')
{
$inprocess = (int)$num;
}
if($status == 'green')
{
$green = (int)$num;
}
if($status == 'red')
{
$red = (int)$num;
}
if($status == 'yellow')
{
$yellow = (int)$num;
}
if($status == 'stopcase')
{
$stopcase = (int)$num;
}
}
}
$total = $inprocess + $green + $red + $yellow + $stopcase;
?>
<div class="row tile_count text-center">
<div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
<a href="<?=site_url('candidate/casetable?total');?>">
<span class="count_top blue"><i class="fa fa-users blue"></i> Total Case</span>
<div class="count blue"><?=$total;?></div>
</a>
</div>
<div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
<a href="<?=site_url('candidate/casetable?inprocess');?>">
<span class="count_top"><i class="fa fa-user-circle"></i> In Process</span>
<div class="count"><?=$inprocess;?></div>
</a>
</div>
<div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
<a href="<?php echo site_url('candidate/casetable?green') ?>">
<span class="count_top green"><i class="fa fa-user-circle green"></i> Green</span>
<div class="count green"><?php echo $green; ?></div>
</a>
</div>
<div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
<a href="<?php echo site_url('candidate/casetable?yellow') ?>">
<span class="count_top yellow"><i class="fa fa-user-circle yellow"></i> Amber</span>
<div class="count yellow"><?php echo $yellow; ?></div>
</a>
</div>
<div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
<a href="<?php echo site_url('candidate/casetable?red') ?>">
<span class="count_top red"><i class="fa fa-user-circle red"></i> Red</span>
<div class="count red"><?php echo $red; ?></div>
</a>
</div>
<!--Stop Case//-->
<div class="col-md-2 col-sm-4 col-xs-6 tile_stats_count">
<a href="<?php echo site_url('candidate/casetable?stopcase') ?>">
<span class="count_top red"><i class="fa fa-user-circle red"></i> Stop Case</span>
<div class="count red"><?php echo $stopcase; ?></div>
</a>
</div>
</div>
<!-- /top tiles -->
<?PHP
if(($this->ion_auth->in_group('client')))
{
?>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="dashboard_graph">
<div class="row x_title">
<div class="col-md-4 text-center">
</div>
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<div id="donut"></div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12 bg-white">
<div class="x_title">
<h3>BGV Performance</h3>
<div class="clearfix"></div>
</div>
<?php
$transition1 = $total != 0 ? ($total/$total * 100): 0;
$transition2 = $total != 0 ? ($inprocess/$total * 100): 0;
$transition3 = $total != 0 ? ($green/$total * 100): 0;
$transition4 = $total != 0 ? ($yellow/$total * 100): 0;
$transition5 = $total != 0 ? ($red/$total * 100): 0;
$transition6 = $total != 0 ? ($stopcase/$total * 100): 0;
?>
<div class="col-md-12 col-sm-12 col-xs-6">
<div>
<p><a href="<?php echo site_url('candidate/index') ?>" class="text-primary">Total Case</a></p>
<div class="">
<div class="progress progress_sm" style="width: 100%;">
<div class="progress-bar bg-blue" role="progressbar" data-transitiongoal="<?php echo $transition1 ?>"></div>
</div>
</div>
</div>
<div>
<p><a href="<?php echo site_url('candidate/index?case=inprocess') ?>" class="text-primary">In Process</a></p>
<div class="">
<div class="progress progress_sm" style="width: 100%;">
<div class="progress-bar bg-default" role="progressbar" data-transitiongoal="<?php echo $transition2 ?>"></div>
</div>
</div>
</div>
<div>
<p><a href="<?php echo site_url('candidate/index?case=green') ?>" class="text-primary"> Green</a></p>
<div class="">
<div class="progress progress_sm" style="width: 100%;">
<div class="progress-bar bg-green" role="progressbar" data-transitiongoal="<?php echo $transition3 ?>"></div>
</div>
</div>
</div>
</div>
<div class="col-md-12 col-sm-12 col-xs-6">
<div>
<p><a href="<?php echo site_url('candidate/index?case=yellow') ?>" class="text-primary"> Amber</a></p>
<div class="">
<div class="progress progress_sm" style="width: 100%;">
<div class="progress-bar bg-yellow" role="progressbar" data-transitiongoal="<?php echo $transition4 ?>"></div>
</div>
</div>
</div>
<div>
<p><a href="<?php echo site_url('candidate/index?case=red') ?>" class="text-primary">Red</a></p>
<div class="">
<div class="progress progress_sm" style="width: 100%;">
<div class="progress-bar bg-red" role="progressbar" data-transitiongoal=" <?php echo $transition5 ?>"></div>
</div>
</div>
</div>
<div>
<p><a href="<?php echo site_url('candidate/index?case=stopcase') ?>" class="text-primary">Stop Case</a></p>
<div class="">
<div class="progress progress_sm" style="width: 100%;">
<div class="progress-bar bg-red" role="progressbar" data-transitiongoal=" <?php echo $transition6 ?>"></div>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?PHP
}
if(($this->ion_auth->in_group('admin')))
{
if($_SESSION['org']!=1)
{
foreach($clients as $row2)
{
$company_name=$row2->company;
$client_code=$row2->client_code;
$query_client_details=$this->db->query("select count(vbasic.id) as num, vbasic.status from basic as vbasic inner join users on vbasic.user_id=users.id where vbasic.Refno like '%".$client_code."%' and users.org=".$this->session->org." group by vbasic.status");
$res_count=array_column($query_client_details->result_array(), 'num', 'status');
$stopcase = $inprocess = $green = $red = $yellow = 0;
foreach($res_count as $key => $data)
{
if($key == 'inprocess') $inprocess = (int)$data;
if($key == 'green') $green = (int)$data;
if($key == 'red') $red = (int)$data;
if($key == 'yellow') $yellow = (int)$data;
if($key == 'stopcase') $stopcase = (int)$data;
}
$total = $inprocess + $green + $red + $yellow + $stopcase;
?>
<div class="row"><br>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="dashboard_graph">
<div class="col-md-offset-3 col-md-6 col-sm-6 col-xs-12 bg-white">
<div class="x_title">
<h3><?PHP echo $company_name; ?></h3>
<div class="clearfix"></div>
</div>
<?php
$transition1 = $total != 0 ? ($total/$total * 100): 0;
$transition2 = $total != 0 ? ($inprocess/$total * 100): 0;
$transition3 = $total != 0 ? ($green/$total * 100): 0;
$transition4 = $total != 0 ? ($yellow/$total * 100): 0;
$transition5 = $total != 0 ? ($red/$total * 100): 0;
$transition6 = $total != 0 ? ($stopcase/$total * 100): 0;
?>
Please help me why am I getting an undefined property error on live server and not on localhost. please someone help solving this error.
you have used $this->data but u have not defined it
$this->load->view('welcome_message', $this->data);
define it in constructor like this :
public function __construct()
{
parent::__construct();
if (!$this->ion_auth->logged_in() || empty($this->session->name))
{
redirect('/login');
}
$this->data = [];
$this->load->helper('url');
$this->load->model('BasicModel', 'basic');
$this->load->model('LabelModel', 'label');
}
for your new error : you are using $mis_green as object
$green= $green+$mis_green->green;
may be its an array kindly check it if its an array use it like this :
$green= $green+$mis_green['green'];
$red= $red+$mis_red['red'];
$yellow= $yellow+$mis_amber['yellow'];
$stopcase= $stopcase+$mis_stop['stop'];
$inprocess= $inprocess+$mis_pending['pending'];