hi there,
i think your "index.ctp" file not correct.
you write
<table>
<php foreach ($ userData as $ data):??>
<tr>
<td> <? php echo $ data ['User'] ['name'];?> </ td>
</ tr>
<php endforeach;??>
</ table>
please write <?php ..... ?> and not <php .... ??>
try this one
<table>
<?php foreach ($userData as $data): ?>
<tr>
<td><?php echo $data['User']['name'];?> </ td>
</ tr>
<?php endforeach; ?>
</ table>
i hope it helps you
Am Dienstag, 2. April 2013 18:26:14 UTC+2 schrieb wen ger0606:
>
> I'm using 2.3.1 cakephp.
> When you run the following simple code, "Notice (8): Undefined index:
> User [APP / View / Users / index.ctp, line 6]" occurs.
> If you run in cakephp 2.3.1 on another server the same code, the error
> does not occur.
>
> --------- UsersController.php -----------
> class UsersController extends AppController {
> public $ uses = array ('User');
> public $ layout = 'default';
> public function index () {
> $ userData = $ this-> User-> find ('all');
> $ this-> set ('userData', $ userData);
> }
> }
>
> --------- User.php -----------
> class User extends AppModel {
> public $ name = 'User';
> }
>
> --------- Index.ctp -----------
> <table>
> <php foreach ($ userData as $ data):??>
> <tr>
> <td> <? php echo $ data ['User'] ['name'];?> </ td>
> </ tr>
> <php endforeach;??>
> </ table>
>
> --------- Debug ($ userData) -----------
> $ userData = array (
> (int) 0 => array (
> (int) 0 => array (
> 'id' => '1 ',
> 'name' => 'suzuki'
> )
> )
> )
>
> Set so the server, I think that there is such a phenomenon occur?
> If there is a point that I noticed something, please advice.
> *best regards*
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.