• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting Error

#1
Hello,

I am facing this error message.  Can anyone help me fix this error?

Setting has been successfully updated!

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: setting
Filename: views/settings.php
Line Number: 52
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\settings.php
Line: 52
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 329
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once


A PHP Error was encountered
Severity: Notice
Message: Undefined variable: success_message
Filename: views/settings.php
Line Number: 45
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\settings.php
Line: 45
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 301
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once

Line 45:  <?php echo $success_message; ?>
Line 52:  <?php foreach($setting as $setting_item): ?>

views/settings.php


PHP Code:
<?php foreach($setting as $setting_item): ?>
                        
                            <tr>
                                <td><b>Contact Information</b></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td><input type="text" name="email" value="<?php echo $setting_item['email']; ?>"></td>
                            </td>    
                            <tr>
                                <td>Site Name</td>
                                <td><input type="text" name="sitename" value="<?php echo $setting_item['site_name']; ?>"></td>
                            </td>
                            <tr>
                                <td></td>
                                <td><br></td>                                
                            </tr>    
                            <tr>
                                <td><b>Site Information</b></td>
                                <td></td>
                            </td>
                            <tr>
                                <td>Meta Title</td>
                                <td><input type="text" name="title" value="<?php echo $setting_item['meta_title']; ?>"></td>
                            </td>
                            <tr>
                                <td>Meta Keyword</td>
                                <td><input type="text" name="keyword" value="<?php echo $setting_item['meta_keyword']; ?>"></td>
                            </td>
                            <tr>
                                <td>Meta Description</td>
                                <td><input type="text" name="description" value="<?php echo $setting_item['meta_description']; ?>"></td>
                            </td>
                            <tr>
                                <td></td>
                                <td><br></td>                                
                            </tr>
                            <tr>
                                <td><b>Social Media Information</b></td>
                                <td></td>
                            </td>
                            <tr>
                                <td>Facebook</td>
                                <td><input type="text" name="facebook" value="<?php echo $setting_item['facebook']; ?>"></td>
                            </td>
                            <tr>
                                <td>Twitter</td>
                                <td><input type="text" name="twitter" value="<?php echo $setting_item['twitter']; ?>"></td>
                            </td>
                            <tr>
                                <td>RSS</td>
                                <td><input type="text" name="rss" value="<?php echo $setting_item['rss']; ?>"></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td><br></td>                                
                            </tr>    
                            <tr>
                                <td></td>
                                <td><input type="submit" name="submit" class="edit" value="Submit"></button>
                            </td>
                            </td>                    
                        
                        <?php endforeach ?>


controllers/Cpages.php

PHP Code:
public function settings() { 
    
        
$data['setting'] = $this->Mpages->call_settings();
        
        
$this->load->view('settings'$data); 
            
    }
    
    public function 
updatesettings() {
        
        
$this->load->helper('form');
        
$this->load->library('form_validation');
        
        
$this->form_validation->set_rules('email''Email''required');
        
$this->form_validation->set_rules('sitename''Sitename''required');
        
$this->form_validation->set_rules('title''Title''required');
        
$this->form_validation->set_rules('keyword''Keyword''required');
        
$this->form_validation->set_rules('description''Description''required');
        
$this->form_validation->set_rules('facebook''Facebook''required');
        
$this->form_validation->set_rules('twitter''Twitter''required');
        
$this->form_validation->set_rules('rss''RSS''required');
        
                
        if (
$this->form_validation->run() === FALSE)
        {    
// return to first 
            
$this->load->view('settings');
        }    
        else
        {
            
$data['success_message'] = 'Setting has been successfully updated!';    
            
            
$this->Mpages->add_settings();
            
$this->load->view('settings'$data);
            
        }
    
    } 
" If I looks more intelligence please increase my reputation."
Reply

#2
It looks like there is no path in your controller in which both $data['success_message'] and $data['setting'] are defined when you load the settings view, and there is at least one path in which neither are defined.
Reply

#3
controllers/Cpages.php


PHP Code:
public function settings() { 
    
        $data
['setting'] = $this->Mpages->call_settings();
        
        $this
->load->view('settings'$data); 
            
}
    



public function updatesettings() {
 
       
        $this
->load->helper('form');
 
       $this->load->library('form_validation');
 
       
        $this
->form_validation->set_rules('email''Email''required');
 
       $this->form_validation->set_rules('sitename''Sitename''required');
 
       $this->form_validation->set_rules('title''Title''required');
 
       $this->form_validation->set_rules('keyword''Keyword''required');
 
       $this->form_validation->set_rules('description''Description''required');
 
       $this->form_validation->set_rules('facebook''Facebook''required');
 
       $this->form_validation->set_rules('twitter''Twitter''required');
 
       $this->form_validation->set_rules('rss''RSS''required');
 
       
                
        if 
($this->form_validation->run() === FALSE)
 
          // return to first 
 
           $this->load->view('settings');
 
          
        else
        
{
 
           $data['success_message'] = "Setting has been successfully updated!"   
            
            $this
->Mpages->add_settings();
 
           $this->load->view('settings'$data);
 
           
        
}
 
   
    
    



Please cek the above code.  I thought it already define the variable:

PHP Code:
$data['setting'] = $this->Mpages->call_settings();

$data['success_message'] = "Setting has been successfully updated!"   
             
" If I looks more intelligence please increase my reputation."
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.