• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why am I getting this DB error?

#1
[eluser]jleequeen[/eluser]
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

distribution_lines

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

My controller:

Code:
class Report extends Controller {

    function Report() {
        parent::Controller();    
    }
    
    function view()    {
        $this->load->model('water_systems_model');
        $this->load->model('distribution_lines_model');
        $this->load->helper('form');
        
        $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:

Code:
class Distribution_lines_model extends Model {
    
    function Distribution_lines_model()    {
        parent::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:

Code:
....
<?php foreach($distribution_lines as $row) { ?>
    <tr>
        <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>
    </tr>
&lt;?php } ?&gt;
....


Messages In This Thread
Why am I getting this DB error? - by El Forum - 06-30-2008, 03:15 PM
Why am I getting this DB error? - by El Forum - 06-30-2008, 03:18 PM
Why am I getting this DB error? - by El Forum - 06-30-2008, 03:22 PM
Why am I getting this DB error? - by El Forum - 06-30-2008, 03:25 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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