Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4033288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:49:47+00:00 2026-05-20T11:49:47+00:00

I have been battling with this code for quite a while and just don’t

  • 0

I have been battling with this code for quite a while and just don’t seem to be able to get it to work.

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!

errors are:

( ! ) 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

and the code which I have combined is:

<?php include 'inc/header.php'; ?>


<?php include 'inc/dbconnect.php'; ?>  


<?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' => $row['prod_id'], 'name' => $row['prod_name'], 'text' => $row['prod_text']);
}

?>


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

        <?php  Print_r ($_SESSION); ?> 

        <div class="partFill">
          <ul>

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

          </ul>
        </div>

      </section>
    </section> <!-- end of ctrCol -->
<?php include 'inc/rightnav.php'; ?>   
<?php include 'inc/footer.php'; ?>   

My apologies if this post isn’t formatted correctly but this is my first post and just getting used to it!

Many thanks all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:49:47+00:00Added an answer on May 20, 2026 at 11:49 am

    Finally got the problem sorted. The issue was that no value was being passed to the variable for the MySQL query.

    I was not using the session’s array properly. To use the ID’s held within the session I had to
    implode the array.

    $sessionProdId = implode(",",$_SESSION['cart']); 
    
    $result = mysqli_query($link, "SELECT prod_id, prod_name, prod_text FROM products WHERE prod_id IN ($sessionProdId)");
    

    This then allows the output to function correctly with the previous code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I have been battling with this problem for a while now. Perhaps there
I've been battling to get this right...basically I have the following HTML setup: <div
I have been battling with this piece of code for literally days now... Would
I have been trying to get this to work. Basically I have a search
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been developing in ASP.NET MVC for a short while. Up to this
I've been battling this for a few hours now, and it may just be
Been battling with this one for what seems, like forever. I have an array:
I have been battling with this for a couple of days. I am trying
Have been searching for this, I need to have a conditional statement in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.