Welcome Guest, Not a member yet? Register   Sign In
Displaying the SQL - Error debugging
#1

[eluser]bcarter[/eluser]
Hi there

I'm trying to display data but it's returning a blank page. I want to find out what the SQL is so that I can work out what the problem is but I don't know how.

Here's the code...

Model
Code:
<?php

class Sub_content_model extends Model {
    
    function Sub_content_model() {
        
        parent::Model();
    }
    
    function sub_content($id, $sid){
        
        $query3 = $this->db->get_where('sub_content', array('section' => $id, 'sub_content_ID' => '$sid'));
        return $query3->result();
    }
}


?>

View
Code:
<?php foreach ($query3 as $row) { ?>
    
    <?php echo $row->sub_content_title ?>
    
    <?php echo $row->sub_content ?>
    
<?php } ?>

<?php $this->load->view('footer') ?>

And the Controller
Code:
function information() {
        
        $id = '2';
        $sid = $this->uri->segment(3);
        $data['page_title'] = "Electrical Courses";
        
        $this->load->model('Nav_model');
        $data['query'] = $this->Nav_model->nav();
        
        $this->load->model('Subnav_model');
        $data['query2'] = $this->Subnav_model->subnav($id);
        
        $this->load->view('head', $data);
        
        $this->load->model('Sub_content_model');
        $data['query3'] = $this->Sub_content_model->sub_content($id, $sid);
        $this->load->view('information_view', $data);
    }

Can somebody help please?!!!

Thanks
#2

[eluser]n0xie[/eluser]
Did you turn database error reporting on in the app/config/database.php ?
#3

[eluser]pickupman[/eluser]
You can use:
Code:
echo $this->db->last_query(); //display last query executed

Or in the controller change to:
Code:
function Your_controller() {
        
        parent::Controller();
        $this->output->enable_profiler('TRUE'); //Display all queries, benchmarks, $_REQUEST array
    }




Theme © iAndrew 2016 - Forum software by © MyBB