title: Cakephp errors relating to findAll() and foreach()
body: <p>I have just completed this tutorial from <a href="http://www.sitepoint.com/application-development-cakephp/" rel="nofollow">http://www.sitepoint.com/application-development-cakephp/</a> as I start my first cakephp project on monday, and I am getting a number of errors and warnings relating to <code>findAll()</code> and <code>foreach()</code>.</p>
  
  <p>Here are the errors:</p>
  
  <pre><code>Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'findAll' at line 1 [CORE\cake\libs\model\datasources\dbo_source.php, line 684].
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Warning (2): Invalid argument supplied for foreach() [APP\views\notes\index.ctp, line 11].
  </code></pre>
  
  <p>Here is the controller:
      
  
  <pre><code>    function index(){
          $this-&gt;set('notes', $this-&gt;Note-&gt;findAll());
      }
  
      function view($id){
          $this-&gt;Note-&gt;id = $id;
          $this-&gt;set('data', $this-&gt;Note-&gt;read());
      }
  
      function add(){
          if (!empty($this-&gt;data['Note']))
          {
              if($this-&gt;Note-&gt;save($this-&gt;data['Note'])){
                  $this-&gt;flash('Your note has been updated.','/notes/');
              }
          }
      }
  
      function edit($id = null){
          if (empty($this-&gt;data['Note'])){
              $this-&gt;Note-&gt;id = $id;
              $this-&gt;data = $this-&gt;Note-&gt;read();
          }
          else{
              if($this-&gt;Note-&gt;save($this-&gt;data['Note']))
              {
                  $this-&gt;flash('Your note has been updated.','/notes/');
              }
          }
      }
  
      function delete($id){
          if ($this-&gt;Note-&gt;del($id)){
              $this-&gt;flash('The note with id: '.$id.' has been deleted.', '/notes');
          }
      }
  
  }
  ?&gt;
  </code></pre>
  
  <p>Here is index.ctp:</p>
  
  <pre><code>&lt;h1&gt;My Notes&lt;/h1&gt;  
      &lt;p&gt;  
      &lt;?php echo $html-&gt;link('Add Note', '/notes/add') ?&gt;  
      &lt;/p&gt;  
      &lt;table&gt;  
      &lt;tr&gt;  
          &lt;th&gt;Id&lt;/th&gt;  
          &lt;th&gt;Title&lt;/th&gt;  
          &lt;th&gt;Created&lt;/th&gt;  
      &lt;/tr&gt;  
      &lt;?php foreach ($notes as $note): ?&gt;  
      &lt;tr&gt;  
          &lt;td&gt;&lt;?php echo $note['Note']['id']; ?&gt;&lt;/td&gt;  
          &lt;td&gt;  
              &lt;?php echo $html-&gt;link($note['Note']['title'], "/notes/view/{$note['Note']['id']}")?&gt;  
          [&lt;?php echo $html-&gt;link('Edit', "/notes/edit/{$note['Note']['id']}")?&gt;,  
          &lt;?php echo $html-&gt;link('Delete', "/notes/delete/{$note['Note']['id']}", null, 'Are you sure?')?&gt;]  
          &lt;/td&gt;  
  
          &lt;td&gt;&lt;?php echo $note['Note']['created']; ?&gt;&lt;/td&gt;  
      &lt;/tr&gt;  
      &lt;?php endforeach; ?&gt;  
      &lt;/table&gt;
  </code></pre>
  
  <p>And here is the database.php file that is in use:</p>
  
  <pre><code>var $default = array(
      'driver'   =&gt; 'mysql',
      'connect'  =&gt; 'mysql_pconnect',
      'host'     =&gt; 'localhost',
      'login'    =&gt; 'root',
      'password' =&gt; '',
      'database' =&gt; 'memo'
      );
  </code></pre>
  
  <p>All supplied code is taken from the tutorial at <a href="http://www.sitepoint.com/application-development-cakephp/" rel="nofollow">http://www.sitepoint.com/application-development-cakephp/</a> .</p>
  
  <p>QUESTION:
  Why is this not working?
  I am using Cakephp 1.3.10.</p>
  
  <p>Any help is appreciated.</p>