undefined index?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

undefined index?

keanoppy

want to ask,i have table stages
but seems that for this particular page,the index cannot be undefined
other than the table and view,where else should i check?
this is the code fragment of the table:
the entire php echo for $stage got error

<?php
$i = 0;
foreach ($stages as $stage):
        $class = null;
        if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
        }
?>
        <tr<?php echo $class;?>>
                <td>
                        <?php echo $stage['Stage']['id']; ?>
                </td>
                <td>
                        <?php echo $html->link($stage['Phase']['id'], array('controller'=>
'phases', 'action'=>'view', $stage['Phase']['id'])); ?>
                </td>
                <td>
                        <?php echo $stage['Stage']['status']; ?>
                </td>
                <td>
                        <?php echo $stage['Stage']['duration']; ?>
                </td>
                <td>
                        <?php echo $html->link($stage['Stagesname']['name'], array
('controller'=> 'stagesnames', 'action'=>'view', $stage['Stagesname']
['id'])); ?>
                </td>
                <td>
                        <?php echo $stage['Stage']['date']; ?>
                </td>
                <td>
                        <?php echo $stage['Stage']['created']; ?>
                </td>
                <td>
                        <?php echo $stage['Stage']['modified']; ?>
                </td>
                <td class="actions">
                        <?php echo $html->link(__('View', true), array('action'=>'view',
$stage['Stage']['id'])); ?>
                        <?php echo $html->link(__('Edit', true), array('action'=>'edit',
$stage['Stage']['id'])); ?>
                        <?php echo $html->link(__('Delete', true), array
('action'=>'delete', $stage['Stage']['id']), null, sprintf(__('Are you
sure you want to delete # %s?', true), $stage['Stage']['id'])); ?>
                </td>
        </tr>
<?php endforeach; ?>
</table>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: undefined index?

brian-9
Which index? What is the table definition? What is the controller
code? What is the output from debug($stages)?

On Mon, Jul 6, 2009 at 8:35 PM, keanoppy<[hidden email]> wrote:

>
> want to ask,i have table stages
> but seems that for this particular page,the index cannot be undefined
> other than the table and view,where else should i check?
> this is the code fragment of the table:
> the entire php echo for $stage got error
>
> <?php
> $i = 0;
> foreach ($stages as $stage):
>        $class = null;
>        if ($i++ % 2 == 0) {
>                $class = ' class="altrow"';
>        }
> ?>
>        <tr<?php echo $class;?>>
>                <td>
>                        <?php echo $stage['Stage']['id']; ?>
>                </td>
>                <td>
>                        <?php echo $html->link($stage['Phase']['id'], array('controller'=>
> 'phases', 'action'=>'view', $stage['Phase']['id'])); ?>
>                </td>
>                <td>
>                        <?php echo $stage['Stage']['status']; ?>
>                </td>
>                <td>
>                        <?php echo $stage['Stage']['duration']; ?>
>                </td>
>                <td>
>                        <?php echo $html->link($stage['Stagesname']['name'], array
> ('controller'=> 'stagesnames', 'action'=>'view', $stage['Stagesname']
> ['id'])); ?>
>                </td>
>                <td>
>                        <?php echo $stage['Stage']['date']; ?>
>                </td>
>                <td>
>                        <?php echo $stage['Stage']['created']; ?>
>                </td>
>                <td>
>                        <?php echo $stage['Stage']['modified']; ?>
>                </td>
>                <td class="actions">
>                        <?php echo $html->link(__('View', true), array('action'=>'view',
> $stage['Stage']['id'])); ?>
>                        <?php echo $html->link(__('Edit', true), array('action'=>'edit',
> $stage['Stage']['id'])); ?>
>                        <?php echo $html->link(__('Delete', true), array
> ('action'=>'delete', $stage['Stage']['id']), null, sprintf(__('Are you
> sure you want to delete # %s?', true), $stage['Stage']['id'])); ?>
>                </td>
>        </tr>
> <?php endforeach; ?>
> </table>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: undefined index?

keanoppy

all index from the stages table, the output for $stage['Phase']['id']
can be shown
for the table stages,i have:
id(pk),phase_id(fk),status,duration,stagesname_id
(fk),p_date,a_date,remarks,created,modified
which part of the controller code?

the output from debug:
include - APP\views\stages\index.ctp, line 31
View::_render() - CORE\cake\libs\view\view.php, line 662
View::render() - CORE\cake\libs\view\view.php, line 376
Controller::render() - CORE\cake\libs\controller\controller.php, line
799
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 230
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
[main] - APP\webroot\index.php, line 88

On Jul 7, 8:51 am, brian <[hidden email]> wrote:

> Which index? What is the table definition? What is the controller
> code? What is the output from debug($stages)?
>
> On Mon, Jul 6, 2009 at 8:35 PM, keanoppy<[hidden email]> wrote:
>
> > want to ask,i have table stages
> > but seems that for this particular page,the index cannot be undefined
> > other than the table and view,where else should i check?
> > this is the code fragment of the table:
> > the entire php echo for $stage got error
>
> > <?php
> > $i = 0;
> > foreach ($stages as $stage):
> >        $class = null;
> >        if ($i++ % 2 == 0) {
> >                $class = ' class="altrow"';
> >        }
> > ?>
> >        <tr<?php echo $class;?>>
> >                <td>
> >                        <?php echo $stage['Stage']['id']; ?>
> >                </td>
> >                <td>
> >                        <?php echo $html->link($stage['Phase']['id'], array('controller'=>
> > 'phases', 'action'=>'view', $stage['Phase']['id'])); ?>
> >                </td>
> >                <td>
> >                        <?php echo $stage['Stage']['status']; ?>
> >                </td>
> >                <td>
> >                        <?php echo $stage['Stage']['duration']; ?>
> >                </td>
> >                <td>
> >                        <?php echo $html->link($stage['Stagesname']['name'], array
> > ('controller'=> 'stagesnames', 'action'=>'view', $stage['Stagesname']
> > ['id'])); ?>
> >                </td>
> >                <td>
> >                        <?php echo $stage['Stage']['date']; ?>
> >                </td>
> >                <td>
> >                        <?php echo $stage['Stage']['created']; ?>
> >                </td>
> >                <td>
> >                        <?php echo $stage['Stage']['modified']; ?>
> >                </td>
> >                <td class="actions">
> >                        <?php echo $html->link(__('View', true), array('action'=>'view',
> > $stage['Stage']['id'])); ?>
> >                        <?php echo $html->link(__('Edit', true), array('action'=>'edit',
> > $stage['Stage']['id'])); ?>
> >                        <?php echo $html->link(__('Delete', true), array
> > ('action'=>'delete', $stage['Stage']['id']), null, sprintf(__('Are you
> > sure you want to delete # %s?', true), $stage['Stage']['id'])); ?>
> >                </td>
> >        </tr>
> > <?php endforeach; ?>
> > </table>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: undefined index?

brian-9

On Mon, Jul 6, 2009 at 9:06 PM, keanoppy<[hidden email]> wrote:
>
> all index from the stages table, the output for $stage['Phase']['id']
> can be shown

If you're getting an "undefined index" error, what is the next word in
the error message? It should tell you which index is undefined.


> for the table stages,i have:
> id(pk),phase_id(fk),status,duration,stagesname_id
> (fk),p_date,a_date,remarks,created,modified
> which part of the controller code?

The part of the controller code that's relevant to this view. Post the
code you have that includes the find() call (or paginate() or however
you're querying the DB).

> the output from debug:
> include - APP\views\stages\index.ctp, line 31
> View::_render() - CORE\cake\libs\view\view.php, line 662
> View::render() - CORE\cake\libs\view\view.php, line 376
> Controller::render() - CORE\cake\libs\controller\controller.php, line
> 799
> Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 230
> Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
> [main] - APP\webroot\index.php, line 88

I meant the output of debug($stages), literally, not the debug message
from the error you're seeing. Put this line at the very top of your
view file:

debug($stages);

Alternatively, put this in the controller, right after your find() call:

die(debug($stages));

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...