Wednesday, April 23, 2014

Re: Notice (8): Undefined variable: user [APP/View/Users/index.ctp, line 12]

hi Archie
are you setting an array called users into your view from your controller?


you should have something like

$users = $this->User->find(‘all’);
$this->set(‘users’,$users);

On 23 Apr 2014, at 10:17, archie rombo <archierombo@gmail.com> wrote:

I recieved the errors below when i tried listing registed users, using this code in /App/View/Users/index.ctp  
<?php foreach ($users as $user): ?>
    <tr>
        <td><?php echo $user['User']; ?></td>
<?php endforeach; ?>
Can Anyone help?

Notice (8): Undefined variable: user [APP/View/Users/index.ctp, line 12]
Warning (2): Invalid argument supplied for foreach() [APP/View/Users/index.ctp, line 12]

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

....................................
Mike Karthäuser
Director, Brightstorm Ltd.

1, Brewery Court
North Street
Bristol
BS3 1JS

mikek@brightstorm.co.uk
www.brightstorm.co.uk
+44(0) 7939252144
....................................

No comments: