Welcome Guest, Not a member yet? Register   Sign In
Why am I getting this DB error?

I can't for the life of me figure out why I keep getting the following error:

Quote:A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distribution_lines' at line 1


Below is my code. Any ideas from anyone would be great!

My controller:

class Report extends Controller {

    function Report() {
    function view()    {
        $pwsid = $this->session->userdata('pwsid');
        $year = $this->session->userdata('year');
        $data['water_system'] = $this->water_systems_model->water_system_info($pwsid);
        $data['distribution_lines'] = $this->distribution_lines_model->get_distribution_lines($pwsid, $year);
        $data['bodyid'] = 'plan';
        $this->load->view('report/view', $data);

My Model:

class Distribution_lines_model extends Model {
    function Distribution_lines_model()    {
    function get_distribution_lines($pwsid, $year) {
        $this->db->where('pwsid', $pwsid);
        $this->db->where('year', $year);
        $this->db->order_by('type', 'asc');
        $query = $this->db->query('distribution_lines');
        return $query->result();

My View:

<?php foreach($distribution_lines as $row) { ?>
        <td class="left">&lt;?php echo $row->type; ?&gt;</td>
        <td>&lt;?php echo $row->size; ?&gt;</td>
        <td>&lt;?php echo number_format($row->percent,2); ?&gt; %</td>
&lt;?php } ?&gt;

get instead of query Smile


Geez. I need to be slapped. It's funny when you look at something 100 times and still can't see something so obvious.

I think we all know the feeling Wink

Theme © iAndrew 2016 - Forum software by © MyBB