On Wed, Jan 19, 2011 at 8:34 PM, tacoparty <[email protected]> wrote:
> Hello,
>
> I am a complete newbie to PHP and especially CakePHP and am going
> through a few tutorials I found online.
>
> The one I'm having problems with is located here:
> http://www.switchonthecode.com/tutorials/cakephp-using-helpers#comment-6644
>
> I've followed all the steps verbatim but when I try to go to the page
> to see the results it returns two error messages. The table headers
> show up but no data.
>
> Undefined variable: data [APP\views\products\index.ctp, line 14]
>
> Invalid argument supplied for foreach() [APP\views\products\index.ctp,
> line 14]
>
> This is what my controller file looks like:
>
> class ProductsController extends AppController
> {
>  var $name = "Products";
>  var $helpers = array('Html');
>
>  function index()
>  {
>    $data = $this->Product->find('all');
>
>    $this->set('data', $data);
>  }
> }

Looks ok to me. Even if the result was empty, $data should exist. Try
adding this right after the call to set():

die(debug($this->viewVars));

Make sure debug is set to 2 in core.php.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to