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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:35:29+00:00 2026-06-15T20:35:29+00:00

I have a shooping cart and I would like to save the $_SESSION[‘cart’] which

  • 0

I have a shooping cart and I would like to save the $_SESSION[‘cart’] which contains the $product_id => $quantity of the products that the user have choosen.
For example:

[cart] => Array
    (
        [366] => 2000
        [215] => 456
    )

First I serialize the $_SESSION[‘cart’] before I INSERT IT in my data base.

<?php
if($_SESSION['cart']) 
{
    $pedido= serialize($_SESSION['cart']);
}
?>

$sql1="insert into pedido(orden) values ('$pedido')";

Now in a different page I want to view the $_SESSION[‘cart’]. So I use:

$sql2 = "SELECT orden FROM pedido where id_pedido = '$ID'";
$rs2 = mysql_query($sql2, $conexio) or die("Error al consultar: ".mysql_error()); 
$row2 = mysql_fetch_row($rs2);
$id_usuario=$row2[0];
$_SESSION['cartguardado']= unserialize($id_usuario);

I know that In this last step I am doing something wrong. Any body could help me and help me finding the mistake?

  • 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-15T20:35:30+00:00Added an answer on June 15, 2026 at 8:35 pm

    Try to output $row2

    $sql2 = "SELECT orden FROM pedido where id_pedido = '$ID'";
    $rs2 = mysql_query($sql2, $conexio) or die("Error al consultar: ".mysql_error()); 
    $row2 = mysql_fetch_row($rs2);
    print_r($row2);
    $id_usuario=$row2[0];
    $_SESSION['cartguardado']= unserialize($id_usuario);
    

    if $row2[0] is empty so something wrong with your data

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

Sidebar

Related Questions

I have an app that I would like to create. But I am not
I have a MySQL table which contains a list of all possible products a
I have a opencart based shopping cart site.. Now I would like to convert
My Shopping Cart Is Here http://jsfiddle.net/bkw5p/48/ in that i would like to show a
I have some animation I would like to try, kind of a shopping cart/checkout
I have a shopping cart that continually logs slow queries like this one... #
I have 2 tables, Products and ShoppingCart and I would like to update and
Hi i'm creating an app which have shopping cart and payment done via paypal
I have an asp based shopping cart that uses html based templates to display
I have a ListView that displays a shopping cart. It was working fine until

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.