title: Call to Member function on Array
body: <p>So I'm utilizing a for each to try to generate a menu dynamically from a MySQL database. Because there's more than one it will always return an array. I use multiple files to generate the menu.
  I use a class to create the menu</p>
  
  <pre><code>class menu extends db{
         public function LoadMainMenu() {
         global $db;
         $query = &lt;&lt;&lt;SQL
         SELECT id,name
         FROM menu
         WHERE enabled = :active
         AND location = :mainmenu
  SQL;
         $resource = $db-&gt;sitedb-&gt;prepare( $query );
         $resource-&gt;execute( array(
         ':active'    =&gt; '1',
         ':mainmenu'  =&gt; '1',
  ));
  foreach($resource as $row){
         echo '&lt;li&gt;&lt;a href="viewPage?pageid='.$row['id'].'"&gt;'.$row['name'].'&lt;/a&gt;&lt;/li&gt;';
     }
  }
  $menu = new menu();
  </code></pre>
  
  <p>My next file is my base.class.php file</p>
  
  <pre><code>function LoadMainMenu() {
  global $menu;
  $menu-&gt;LoadMainMenu();
  }
  </code></pre>
  
  <p>Then I have my index.php file within my theme settings where I have it called</p>
  
  <pre><code>&lt;ul class='topmenu'&gt;
  &lt;?php LoadMainMenu(); ?&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>It then gives me the error that it's a call to a member function on an array on base.class.php; If anymore code would help please let me know. </p>