Error:
(POST <http://localhost/codeigniter/Purchase/transaction/update?id=7> 500 (Internal Server Error) 

```
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 ''supp_id2` = 
s.`supp_id` WHERE p.purch_id =' at line 1

SELECT p.*, s.supp_name FROM purchase as p LEFT JOIN supplier as s ON 
p.'supp_id2` = s.`supp_id` WHERE p.purch_id =

Filename: C:/xampp/htdocs/codeigniter/system/database/DB_driver.php

Line Number: 691

```

this is the Controller of my code, this is where the transaction is located at

```
function transaction($txn = null) {
    switch ($txn) {
        case 'list':

            $response['data']=$this->Purchase_model->get_all_purchase();
            echo json_encode($response);

        break;

        case 'create':
            $purchase = 
            array(
                'po_number' => $this->input->post('po_number'),
                'date' => $this->input->post('date'),
                'supp_id2' => $this->input->post('supp_id2'),
                'contact_person' => $this->input->post('contact_person'),
                'delivered_to' => $this->input->post('delivered_to'),
                'plu_number' => $this->input->post('plu_number'),
                'address' => $this->input->post('address'),
                'remarks' => $this->input->post('remarks'),
            );

            $insert = $this->Purchase_model->purchase_add($purchase);

            $resp['row_added'] = $this->Purchase_model->get_purchase($insert);
            $resp['title'] = 'Success!';
            $resp['stat'] = 'success';
            $resp['msg'] = 'Purchase Information successfully created.';

            echo json_encode($resp);
        break;

        case 'update':
            $data = 
            array(
                'po_number' => $this->input->post('po_number'),
                'date' => $this->input->post('date'),
                'supp_id2' => $this->input->post('supp_id2'),
                'contact_person' => $this->input->post('contact_person'),
                'delivered_to' => $this->input->post('delivered_to'),
                'address' => $this->input->post('address'),
                'plu_number' => $this->input->post('plu_number'),
                'remarks' => $this->input->post('remarks'),
            );

```

this is the purchase model I created

```
 public function get_purchase($purch_id)
 {
    $db = "SELECT p.*, s.supp_name FROM purchase as p LEFT JOIN supplier as 
 s ON p.'supp_id2` = s.`supp_id` WHERE p.purch_id = $purch_id ";
 return $this->db->query($db)->result();-
    $this->db->from($this->table);
    $this->db->where('purch_id',$id);
    $query = $this->db->get();

    return $query->row();
}   

```

if you need to see the other details please ask so a I can send it to the comment section or edit this post, how to solve this? 

**UPDATE:**

I changed the 'supp\_id2`to`supp\_id2` and it shows a new but I think the same error:

```
 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 '' at line 1

 SELECT p.*, s.supp_name FROM purchase as p LEFT JOIN supplier as s ON 
 p.`supp_id2` = s.`supp_id` WHERE p.purch_id =

 Filename: C:/xampp/htdocs/codeigniter/system/database/DB_driver.php

 Line Number: 691                                                                                   

```