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

  • Home
  • SEARCH
  • 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 8671777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:02:08+00:00 2026-06-12T19:02:08+00:00

I have a session array [cart] of which contains user id numbers. I am

  • 0

I have a session array [cart] of which contains user id numbers. I am trying to generate a list of email addresses from the contact table WHERE the contact id numbers in the session = the contact_id in the database.

Here is my code.

// Find cart members from the session array
foreach ($_SESSION['cart'] as $key=>$val) {
    $contactid = $val;

    // Query the database for cart members
    $cartresult = mysql_query("SELECT contact.email FROM contact WHERE contact.contact_id = '$contactid'");
    $emailresult = mysql_query($emailquery) or DIE (mysql_error());
    while ($r = mysql_fetch_array($emailresult)) { 
        $emailAry[] = $r['email']; 
    }
}

// Create comma separated list from email array
if (count($emailAry)) {
    $list = implode(", ", $emailAry);

    $list = str_replace(" ,", "", $list);

Apparently there is no value for $emailAry because the if statement is being neglected.

Any idea why this would be?

  • 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-06-12T19:02:10+00:00Added an answer on June 12, 2026 at 7:02 pm

    $emailquery from my perspective is undefined.

        $emailAry = array();
    
        // Find cart members from the session array
        foreach ($_SESSION['cart'] as $key=>$val) {
            $cartresult = mysql_query("SELECT email FROM contact WHERE contact_id = '$val'");
            while ($r = mysql_fetch_array($cartresult)) { 
                $emailAry[] = $r['email']; 
            }
        }
    
        // Create comma separated list from email array
        if (count($emailAry)) {
            $list = implode(",", $emailAry);
    
            // no need to replace ', ' with '', implode will do all the job creating a CSV :)
            //$list = str_replace(" ,", "", $list);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array which gets from session, this is print_r of array print_r($_SESSION['wpsc_cart']); wpsc_cart
for example i have Session::instance()->get('orders') which is an array of some arrays: $first =
I have a shopping cart array, which has a variable to tell me if
I have the following data from print_r($_SESSION) : Array ( [totalprice] => 954 [cart]
I have CSV text thats stored in the session array as csv. The lines
I have a certain session variable that is actually an array. I want to
I have a multi-array stored in a SESSION I loop through the data in
Should I constantly have a session open in my web site with user accounts,
Hi I have created session array : int[] a = (int[])Session[values]; Now i have
I have a Session which I am using to hold items in a form

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.