如何修复此错误消息?
遇到PHP错误
严重性:注意
消息:未定义的变量:success_message
文件名:views / editclients.php
行号:40
回溯:
文件:C:\ Program Files (86)\的EasyPHP-DevServer-14.1VC9 \数据\ localweb \ EcommerceGiondaCI \应用\视图\ editclients.php 行:40功能:_error_handler
文件:C:\ Program Files (86)\的EasyPHP-DevServer-14.1VC9 \数据\ localweb \ EcommerceGiondaCI \应用\控制器\ Cpages.php 行:343功能:视图
文件:C:\ Program Files (86)\的EasyPHP-DevServer-14.1VC9 \数据\ localweb \ EcommerceGiondaCI \的index.php 行:315功能: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 :(得分:1)
这是一个通知错误,因为在您的页面上有时未声明success_message变量,请使用以下代码
<?php if (isset($success_message)) { echo $success_message; } ?>