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 7752157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:43:41+00:00 2026-06-01T11:43:41+00:00

This is a web app that works when user searches for an item to

  • 0

This is a web app that works when user searches for an item to add to their list and the search results show an item that has previously been added to their list.

However, if the search results find an item that has not previously been added to the user’s list then the user should be able to add this new item to their list.

Here’s the the first function which works for adding an item that was previously on a user’s list; (note the “if ($user_item_id == ‘null’ …” line… this should be calling a second function called “addToUserItems”)

function addItem() {
    $user_item_id = $this->uri->segment( 3 );
    $master_item_id = $this->uri->segment( 4 );
    $store = $this->uri->segment( 5, '' );
    $user_id = $this->main_model->getMasterUser( $this->user_id );

    if ( $user_item_id == 'null' ) $user_item_id = $this->main_model->addToUserItems( $master_item_id, $user_id );
    $quantity = $this->main_model->addToShoppingList( $user_item_id, $store, $user_id );

    $message  = ( $quantity == '1' ) ? 'Added to list.' : 'On shopping list ' . $quantity . ' times.';
    $message .= '&nbsp; &nbsp; <span class="undo_button" params="unadd/' . $user_item_id . '">Undo?</span>';

    $return = array(
        'message'      => $message,
        'user_item_id' => $user_item_id,
        );
    echo json_encode( $return );
    }

Here’s the second function which should be setting “user_item_id” but apparently is not;

function addToUserItems( $master_item_id, $user_id ) {
    $query = $this->db->query( "
        INSERT INTO user_item ( master_item_id, user_id, custom_category, custom_name, custom_store, expires_after, on_hand )
        SELECT id, " . $user_id . ", original_category, original_name, '', default_expiration, 0
        FROM master_item
        WHERE id = '" . $master_item_id . "'
        ;" );
    return $this->db->insert_id();
    }

Any ideas why we are seeing “user_item_id” undefined? My guess, after hours of testing assumptions, is that somehow the second function is not setting the value for $user_item_id.

  • 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-01T11:43:42+00:00Added an answer on June 1, 2026 at 11:43 am

    thanks for the suggested fixes; turns out that the user_item_id variable was not being set if the user_item_id field did not have a value. code in other file corrected to include $result[‘user_item_id’] = ‘null’; furthermore, the addItem function above was looking for a user_item_id variable value of ‘null’ whereas a javascript file, not mentioned in my original question, was looking for the user_item_id variable to be null. so, we had a variable that needed to be set and code in other files which needed to look consistently for ‘null’ vs null.

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

Sidebar

Related Questions

I'm writing a web app that supports multiple users. Each user has their own
I have inherited a working VB.NET 2.0 web app that has several User Controls
I have this c# web app that relies heavily on two dll files that
So I'm working on this site web app that should let users easily chat
This is about a web app that serves images. Since the same request will
I have a SQL query in my ASP.net web app that looks like this:
I have a web-app that has a master mysql db and four slave dbs.
I am creating an iOS web app that has a fixed div (say 200px
I'm working on a web app that currently has a table-based layout. Ideally I'd
I have a php based web app that on a user entering a value,

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.