2017-03-18 99 views
0

如何解決此錯誤消息?未定義變量:success_message


甲PHP錯誤遇到

嚴重性:注意

消息:未定義變量:success_message

文件名:視圖/ editclients.php

行號:40

回溯:

文件:C:\ Program Files文件 (86)\的EasyPHP-DevServer-14.1VC9 \ DATA \ localweb \ EcommerceGiondaCI \程序\意見\ editclients.php 行:40功能:_error_handler

文件:C:\ Program Files文件 (86)\的EasyPHP-DevServer-14.1VC9 \數據\ localweb \ EcommerceGiondaCI \應用\控制器\ Cpages.php 線:343功能:視圖

文件:C:\ Program Files文件 (x86)\ EasyPHP-DevServer-14.1VC9 \ data \ localweb \ EcommerceGiondaCI \ index.php Line:315 Fun ction:require_once

的意見/ editclients.php

   <?php echo $success_message; ?> 

       <?php echo validation_errors(); ?> 

       <?php foreach ($clients as $clients_item): ?> 

       <div class="widget-box"> 
        <div class="widget-title"><h5>Parent Categories</h5></div> 
        <div class="widget-content"> 

        <?php echo form_open('cpages/editclientsupdate/'.$clients_item['client_id']); ?> 
        <table border="0" style="width: 80%; height: 90px;"> 
         <tr> 
          <td>FIRST NAME</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_firstname']; ?>"></td> 
         </tr> 
         <tr> 
          <td>LAST NAME</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_lastname']; ?>"></td> 
         </tr> 
         <tr> 
          <td>ADDRESS LINE1</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_addressline1']; ?>"></td> 
         </tr> 
         <tr> 
          <td>ADDRESS LINE2</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_addressline2']; ?>"></td> 
         </tr> 
         <tr> 
          <td>CELLPHONE</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_cellphone']; ?>"></td> 
         </tr> 
         <tr> 
          <td>STATE</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_state']; ?>"></td> 
         </tr> 
         <tr> 
          <td>CITY</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_city']; ?>"></td> 
         </tr> 
         <tr> 
          <td>COUNTRY</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_country']; ?>"></td> 
         </tr> 
         <tr> 
          <td>EMAIL</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_email']; ?>"></td> 
         </tr> 
         <tr> 
          <td>MOBILE</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_cellphone']; ?>"></td> 
         </tr> 
         <tr> 
          <td>STATUS</td> 
          <td><input type="text" name="newsletter" value="<?php echo $clients_item['client_status']; ?>"></td> 
         </tr> 
         <tr> 
          <td></td> 
          <td><input type="submit" class="edit" name="submit" value="SUBMIT"></td> 
         </tr> 
        </table>    
        </div> 
       </div> 

       <?php endforeach; ?> 

控制器/ Cpages.php

public function editclientsupdate() { 


    $client_id = $this->uri->segment(3); 

    $data['clients'] = $this->pages_model->call_clients_point($client_id); 

    $this->load->helper('form'); 
    $this->load->library('form_validation'); 

    $this->form_validation->set_rules('client_firstname', 'Client First Name', 'required'); 
    $this->form_validation->set_rules('client_lastname', 'Client Last Name', 'required'); 
    $this->form_validation->set_rules('client_addressline1', 'Client Address Line1', 'required'); 
    $this->form_validation->set_rules('client_addressline2', 'Client Address Line2', 'required'); 
    $this->form_validation->set_rules('client_cellphone', 'Client Cell Phone', 'required'); 
    $this->form_validation->set_rules('client_state', 'Client State', 'required'); 
    $this->form_validation->set_rules('client_city', 'Client City', 'required'); 
    $this->form_validation->set_rules('client_country', 'Client Country', 'required'); 
    $this->form_validation->set_rules('client_email', 'Client Email', 'required'); 
    $this->form_validation->set_rules('client_cellphone', 'Client Cellphone', 'required'); 
    $this->form_validation->set_rules('client_status', 'Client Status', 'required'); 


    if ($this->form_validation->run() === FALSE) 
    { // return to first 

     $data['success_message'] = ""; 

     $this->load->view('editclients', $data); 

    } 
    else 
    { 
     $data['success_message'] = "Setting has been successfully updated!";  


     $this->pages_model->update_clients($client_id); 

     $this->load->view('editclients', $data); 

    } 

} 
+0

在什麼時候錯誤發生。它是在第一頁加載?從你的代碼中可以看出你正在設置它。 – PaulD

+0

是的,在第一頁加載。 – David

+0

表單驗證 - >運行返回布爾值TRUE或FALSE。嘗試將IF測試更改爲== FALSE,而不是=== FALSE。這是否改變了行爲?我不確定這是什麼原因,因此回答評論。 – PaulD

回答

1

這是一個通知錯誤,因爲您的網頁上有時success_message變量未聲明,使用以下代碼

<?php if (isset($success_message)) { echo $success_message; } ?>