2013-08-24 46 views
0

我在更新數據庫行時發生錯誤。錯誤更新代碼行中的行

我的問題是沒有更新行,並打電話給我,當我上傳圖片更新文件上傳未定義索引。

我的控制器:

public function addedit(){ 

    $events = new events_model(); 
    $prodID = $this->input->post('hID'); 
    $text = $this->input->post('ev_text'); 
    $pic = $this->do_upload('ev_pic'); 
    $submit = $this->input->post('submit'); 

    if($submit){ 

     if(!empty($prodID)){ 

      $this->data['events'] = $events->UpdatePost($prodID, $text , $pic); 
      $this->data['pagetitle'] = "Show Info";    
      $this->data['success']= "Update Done"; 

     }else{ 

      $this->data['success'] = "Add Done"; 
     } 

    $this->data['status'] = "1"; 

    }else{ 

     $this->data['status'] = "0"; 
     $this->data['errors'] = "Error"; 
    } 

    $this->template->build('admin/events/add',$this->data); 
} 

和型號:

function UpdatePost($prodID, $text , $pic) { 

    if ($pic == ""){ 

     $vales = array('ev_id' => $prodID , 'ev_text' => $text); 

    }else{ 

     $vales = array('ev_id' => $prodID , 'ev_text' => $text , 'ev_pic' => $pic); 
    } 

    $query = $this->db->update($this->table_name, $vales) or die (mysql_error()); 
    $result = array(); 
    $result["process"] = "ok"; 
    echo "1";  
} 

和看法:

<div class="widget-body"> 

      <table class="data-table" action="./administrator/categories/delete/"><!-- Table Conversion: See Section E in custom.js --> 
       <thead> 
        <tr> 
         <th class="sorting no-background" rowspan="1" colspan="1" style="width: 35px;"><input type="checkbox" id="checkall" /></th> 
         <th class="sorting" rowspan="1" colspan="1" style="width: 343px;">Tittle</th> 
         <th class="sorting" rowspan="1" colspan="1" style="width: 100px;">Date</th> 
         <th class="sorting no-background" rowspan="1" colspan="1" style="width: 70px;">#</th> 
        </tr> 
       </thead> 
       <tbody> 
        <?php $ctr = 0; ?> 
        <?php foreach ($events as $n): ?> 
          <tr> 
           <td><input class="checkrow" type="checkbox" value="<?php echo $n->ev_id; ?>" /></td> 
           <td class=" sorting_1"><?= $n->ev_text; ?></td> 
           <td class="center"><?= $n->ev_date; ?></td> 
           <td> 
            <a href="<?php echo $this->page_url; ?>/edit/<?php echo $n->ev_id; ?>" class="ico-btn ico-text-edit" title="Edit"><span>Edit</span></a> 
            <a href="<?php echo $this->page_url; ?>/delete/<?php echo $n->ev_id; ?>" itemID="<?= $n->ev_id ?>" class="ico-btn ico-text-trash opener-delete" title="Del"><span>Del</span></a> 
           </td> 
          </tr> 
        <?php endforeach ?> 
       </tbody> 

      </table> 



      <div class="clear"></div> 
     </div> 
     <div class="clear"></div> 
    </div> 

    <div id="table-extra"> 
     <div id="table-action"> 
      <input action="./administrator/<?php echo $this->uri->segment(2)."/deleteitems" ?>" class="btn-theme table-button btn-hover-black DeleteItems" id="submit" type="button" value="Delete" /> 
     </div> 
     <div class="paginate"> 
      <ul> 
       <?= $this->pagination->create_links(); ?> 
      </ul> 
      <div class="clear"></div> 
     </div> 

     <div class="clear"></div> 
    </div> 
</div> 
</div> 

其中的問題在我的代碼,而我不會更新成功。

回答