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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:00:17+00:00 2026-05-26T16:00:17+00:00

Hello everyone this is my first post on stack overflow.com I am trying to

  • 0

Hello everyone this is my first post on stack overflow.com
I am trying to create shopping cart. Values are being stored in a session in two dimension table. First value represents item id in database, second – quantity of item.

foreach($cart_array as $row){
    $sql = "SELECT * FROM prod_table WHERE id=".$row['0']."";
    $cart_result = mysql_query($sql, $conn);
    while ($array = mysql_fetch_array($cart_result)) {
        echo "<tr><td>". $array[manufacturer] . "</td>";
        echo "<td>". $array[model]."</td>";
        echo "<td>".$row['1']."</td>";
        $cart_value = $array[price]*$row['1'];
        //sum and store value of all products
        $total_cart_value += $cart_value;
        echo "<td>&pound;" .$cart_value. "</td>";
        echo "<td><a href='search.php?kick_id=".$row['0']."'>Remove</a></td></tr>";

OK, to remove item form cart user clicks remove and then he is being send back to the same page ( for some reason I had difficulty to use $_SERVER[‘PHP_SELF’} with GET method… )
and then different part of code is being triggered which is going to remove pair of values from $cart_array, using unset function.

if(isset($_GET['kick_id'])) {
    $t = count($cart_array);
    for( $u = 0; $u < $t; $u++){
        if ($cart_array[$u]['0'] == $_GET['kick_id']){
            unset($cart_array[$u]['0']);
            unset($cart_array[$u]['1']);
            echo " Item has been removed from your cart";
            $cart_array = array_values($cart_array); 

And it actually removes pair of values but, now instead of running smoothly it displays error message :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource …
I assume that there must be some “trace” of deleted values in session array which is causing error.
How to fix code ?
Is there any other method/approach to delete values ??

  • 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-26T16:00:18+00:00Added an answer on May 26, 2026 at 4:00 pm

    I assume that…

    that is what you are doing wrong.
    A programmer should never “assume”. A programmer can (and should) be certain.
    Assumptions will lead you astray and waste your time (as well as other people’s time when you ask a question).

    So, you have to do some debugging – an investigation to find the actual cause of the problem.
    supplied argument is not a valid MySQL result resource error means there was an error in the query. So, you have to see what error it was. So, run all yoiur queries in the manner which let you to see any error occurred. A simplest way would be

    $cart_result = mysql_query($sql, $conn) or trigger_error(mysql_error()." in ".$sql);
    

    and run your code again.
    you will find an sql error in their usual place – a screen or a log file.

    If you’ll be unable to get the meaning of the error and correct your code yourself – it’s time to ask a question. A certain and direct question, not vague question out of some assumptions. Gotcha?

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

Sidebar

Related Questions

This is my first post on stackoverflow, hello everyone! My first venture into jQuery
hello everyone im trying to create this tweak that copies a file from one
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello everyone i currently have this: import feedparser d = feedparser.parse('http://store.steampowered.com/feeds/news.xml') for i in
Hello everyone, I have been banging my head really hard trying to solve this
Hello everyone I'm currently trying to create a deferred renderer for my graphics engine
Hello everyone I'm trying to work with jboss messaging, does anyone knows the default
Hello everyone I'm trying to improve my Java skills by solving some problems from
First question here so hello everyone. The requirement I'm working on is a small
Hello everyone I been trying get php uploader working but having a lot of

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.