Welcome Guest, Not a member yet? Register   Sign In
Edit Pages
#1

How to fix this error message?

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/editpages.php
Line Number: 49
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\editpages.php
Line: 49
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 269
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once



Line 49: 

PHP Code:
<?php foreach ($pages as $pages_item): ?>


views/editpages.php


PHP Code:
<?php //$pages=array(); ?>
                    
                    <?php foreach ($pages as $pages_item): ?>
                    
                    <div class="widget-box">
                        <div class="widget-title"><h5>Pages</h5></div>
                        <div class="widget-content">
                        
                        <?php echo form_open('cpages/editpagesupdate'); ?>
                        <table border="0" style="width: 100%; height: 90px;">
                            <tr>
                                <td>Pages Name</td>
                                <td><input type="text" name="pages_name" value="<?php echo $pages_item['pages_name']; ?>"></td>
                            </td>
                            <tr>
                                <td>Create Date</td>
                                <td><input type="text" name="create_date" value="<?php echo $pages_item['create_date']; ?>"></td>
                            </td>    
                            <tr>
                                <td>Order</td>
                                <td><input type="text" name="pages_order" value="<?php echo $pages_item['pages_order']; ?>"></td>
                            </td>
                            <tr>
                                <td>View Content</td>
                                <td><textarea rows="3" cols="20" name="pages_content"><?php echo $pages_item['pages_content']; ?></textarea></td>
                            </td>
                            <tr>
                                <td></td>
                                <td><input type="submit" class="edit" name="submit" value="SUBMIT"></td>
                            </tr>
                        </table>            
                        </div>
                    </div>        

                    <?php endforeach; ?>
                    
                </div>
            </div> 
" If I looks more intelligence please increase my reputation."
Reply
#2

When are you going to quit writing code and start to learn the languages and frameworks?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Sorry, I thought that is CI framework. And I know somethings about php - already 4 years with php. Eventhough some errors makes me question something?
" If I looks more intelligence please increase my reputation."
Reply
#4

Davy: the error message you are questioning is pure PHP ... "Invalid argument supplied for foreach()".
The $pages variable is either empty or undefined.
That should be apparent to someone with four years of PHP Sad
Reply
#5

Should be apparent with four weeks of php.
Reply
#6

Lol. I think I am still new in this part and perhaps better on other part. I already read the manual and still do not understand it.

http://php.net/manual/en/control-structures.foreach.php

I try to activate this:

<?php $pages=array(); ?>

<?php foreach ($pages as $pages_item): ?>
" If I looks more intelligence please increase my reputation."
Reply
#7

This is the models:

models/Mpages.php


PHP Code:
public function update_pages($pages_id)
    {
        
        
$data = array(
            
'pages_name' => $this->input->post('pages_name'),
            
'create_date' => $this->input->post('create_date'),
            
'pages_order' => $this->input->post('pages_order'),
            
'pages_content' => $this->input->post('pages_content')
        );
    
        
$this->db->where('pages_id'$pages_id);
        return 
$this->db->update('pages'$data);
        
    } 
" If I looks more intelligence please increase my reputation."
Reply
#8

Learn to program in PHP
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

I have read the tutorial. I only do not know how to fix this error message:


A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/editpages.php
Line Number: 49
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\editpages.php
Line: 49
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php
Line: 269
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php
Line: 315
Function: require_once



Line 49:

PHP Code:
<?php foreach ($pages as $pages_item): ?>
" If I looks more intelligence please increase my reputation."
Reply
#10

Davy: I repeat, the $pages variable is either empty or undefined.

The model snippet you provided earlier does not set $pages, as far as I can see.

In line 49 of your post above, where does $pages come from????????????
It is empty or undefined!!!!!!!!!!!!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB