Thursday, April 24, 2014

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

Think of it this way, ['User'] is the model name and ['id'] is the fieldname from the database table, that said you can do something like this:

echo $user['User']['id'];
echo $user['User']['username'];
echo $user['User']['created']; 

Obviously you may want to do more than just this, you may want to refer back to the blog tutorial in the cakephp documentation. I would complete that first to get to grips:



On 24 April 2014 10:10, archie rombo <archierombo@gmail.com> wrote:
i have changed my code as you advised, but now its only showing user id but username is blank


On Wednesday, April 23, 2014 12:17:30 PM UTC+3, archie rombo 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.



--
Kind Regards
 Stephen Speakman

--
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.

No comments: