For each problem / PHP Notice: Undefined variable
<p>I have been battling with this code for quite a while and just don't seem to be able to get it to work. </p>

<p>Have tried quite a few variants of the configuration but to no avail. The most confusing part is that it works absolutely fine for displaying a product catalogue (with different variables) but just not this!</p>

<p>errors are:</p>

<pre><code>( ! ) Notice: Undefined variable: quotes in C:\wamp\www\longlifedecking\quote.php on line 40 Call Stack
#   Time    Memory  Function    Location 1  0.0089  689992  {main}( )   ..\quote.php:0

( ! ) Warning: Invalid argument supplied for foreach() in C:\wamp\www\longlifedecking\quote.php on line 40 Call Stack
#   Time    Memory  Function    Location 1  0.0089  689992  {main}( )   ..\quote.php:0
</code></pre>

<p>and the code which I have combined is:</p>

<pre><code>&lt;?php include 'inc/header.php'; ?&gt;


&lt;?php include 'inc/dbconnect.php'; ?&gt;  


&lt;?php
// Quotes link from Nav

$sessionProdId = $_SESSION["cart"];


$result = mysqli_query($link, "SELECT prod_id, prod_name, prod_text FROM products WHERE prod_id ='$sessionProdId'");
if (!$result)
{
$error = 'Error fetching products: ' . mysqli_error($link);
include 'error.php';
exit();
}
while ($row = mysqli_fetch_array($result))
{
$quotes[] = array('id' =&gt; $row['prod_id'], 'name' =&gt; $row['prod_name'], 'text' =&gt; $row['prod_text']);
}

?&gt;


    &lt;section id="ctrCol" class="fl"&gt;
      &lt;section class="partFill lrgMod ctr"&gt;
        &lt;header&gt;
          &lt;h1&gt;Quote me&lt;/h1&gt;
        &lt;/header&gt;
        &lt;p&gt;Your shopping cart contains &lt;?php echo count($_SESSION['cart']); ?&gt; items.&lt;/p&gt;

        &lt;?php  Print_r ($_SESSION); ?&gt; 

        &lt;div class="partFill"&gt;
          &lt;ul&gt;

          &lt;?php foreach ($quotes as $quote): ?&gt;
            &lt;li&gt;
              &lt;h3&gt;&lt;?php echo htmlspecialchars($quote['name'], ENT_QUOTES,'UTF-8'); ?&gt;&lt;/h3&gt;
              &lt;p&gt;&lt;?php echo htmlspecialchars($quote['text'], ENT_QUOTES,'UTF-8'); ?&gt;&lt;/p&gt;
             &lt;/li&gt;
          &lt;?php endforeach; ?&gt;

          &lt;/ul&gt;
        &lt;/div&gt;

      &lt;/section&gt;
    &lt;/section&gt; &lt;!-- end of ctrCol --&gt;
&lt;?php include 'inc/rightnav.php'; ?&gt;   
&lt;?php include 'inc/footer.php'; ?&gt;   
</code></pre>

<p>My apologies if this post isn't formatted correctly but this is my first post and just getting used to it!</p>

<p>Many thanks all.</p>
