• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error creating in my controller

#3
Controller (application/controllers/Home.php)

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Home extends CI_Controller {

 public function 
index()
 {
 
$this->load->model('user_model');

 
$data = array();

 
$regno $this->session->userdata('username'); 
 
$data['appdetails_show'] = $this->user_model->getapp($regno);

 
$this->load->view('welcome_message',$data);
 }


Model (application/models/User_model.php)

PHP Code:
<?php
class User_model extends CI_Model {

 public function 
getapp($regno){
 
 
$this->db->select('*');
 
$this->db->from('appdetpayment');
 
$this->db->where('appdetpayment.regno',$regno);  
 $this
->db->order_by('appdetpayment.appno');
 
$query $this->db->get();
 return 
$query->result_array();

 }



IMPORTANT!! in application/config/autoload.php add database and session libraries. Example:
PHP Code:
$autoload['libraries'] = array('database','session'); 

With this works! Please check the $regno variable in controller. Sometimes can be null and generate a invalid SQL.
Reply


Messages In This Thread
error creating in my controller - by kvanaraj - 09-19-2018, 12:13 AM
RE: error creating in my controller - by Pertti - 09-19-2018, 01:37 AM
RE: error creating in my controller - by davidgv88 - 09-19-2018, 01:48 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.