php - codeigniter- insert data into db not working -


when click on submit button keep getting message "your menu not added, please try again" while code working before after committing on svn not working , data being inserted db

controller:

 public function addmenu() {      $this->load->model('organizer_model');      $data = array(                  $data['email']=$this>session>userdata('email');                 'menu_name' => $posted_data['menu name'],                 'price' => $posted_data['price']             );              if($this->organizer_model->insertmenu($data)) {      $this->session->set_flashdata('message', 'your menu has been added');     redirect('/menu/index', 'refresh');      } else {      $this->session->set_flashdata('message', 'your menu not added, please try again');     redirect('/menu/index', 'refresh');     }  } 

model:

  public function insertmenu($data) {      $condition = "email = '" . $data['email'] . "'";     $this->db->select('organizer_id');     $this->db->from('organizer');     $this->db->where($condition);     $this->db->limit(1);     $query = $this->db->get();      if ($query->num_rows() > 0){          array_pop($data); //will remove email data          $row = $query->row();         $data['organizer_id'] = $row->organizer_id;          $this->db->insert('menu', $data);         if ($this->db->affected_rows() > 0) {             return true;         } else {             return false;         }     } else {         return false;     }  } 

here view:

  <div class="widget-body">                 <?php echo $this->session->flashdata('message'); ?>                  <form action="<?php echo site_url('organizer/addmenu'); ?>" method="post" class="form-horizontal no-margin">                    <div class="control-group">                     <label class="control-label" for="name">                      menu name                     </label>                     <div class="controls controls-row">                       <input class="span3" name="data[menu name]" type="text" placeholder="enter menu name">                     </div>                   </div>                    <div class="control-group">                     <label class="control-label" for="price">                       price                     </label>                     <div class="controls controls-row">                       <input class="span3" name="data[price]" type="text" placeholder="">                     </div>                   </div>                    <div class="form-actions no-margin">                     <button type="submit" name="submit" class="btn btn-info pull-right">                       add menu                     </button>                     <div class="clearfix">                     </div>                   </div>                  </form>      </div> 

before go further in project; turn on error reporting

array(   $data['email']=$this>session>userdata('email');   'menu_name' => $posted_data['menu name'],   'price' => $posted_data['price'] ); 

this not proper syntax.

what wanted this.

array(   'email' => $this->session->userdata('email'),   'menu_name' => $posted_data['menu name'],   'price' => $posted_data['price'] ); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -