I have a problem, Whenever I add the number to my session, I recieve an error say Undefined index: cart_1 in D:\wamp\www\MiniCart\cart.php on line 100
And when I press the add key the error repeats on top yet still giving the output and upon refreshing it works fine and adds a new to the stored data. I don't understand why I am getting this, If I dont add 1 to it then it works fine in displaying.

Cart.php

<!DOCTYPE>
<html>
<head>

</head>

<body>
<?php
session_start();

//The page where to jump to after adding/editing cart.
$page = 'mini_cart_index.php';

$link = mysqli_connect("localhost","root","","cart");

if(mysqli_connect_errno())
{
    echo "Error:".mysqli_connect_error();
    echo "<br/>";
}
else
{
    echo "Connected to SQL<br/>";
}


//==================================================

    if(isset($_GET['add']))
{
    $obt=$_GET['add'];
    $quantity_limit = 'SELECT id,quantity FROM products WHERE id='.mysqli_real_escape_string($link,(int)$_GET['add']);

$quantity = mysqli_query($link,$quantity_limit);

    while($quantity_row=mysqli_fetch_assoc($quantity))
    {
        if($quantity_row['quantity']!=$_SESSION['cart_'.$_GET['add']])
        {
            $_SESSION['cart_'.$_GET['add']]+='1';

        }
    }

/*  
    echo 'id='.$obt.' '.'next<br/>';
    echo 'Now storing info into session variable and adding one<br/>';
    echo $_SESSION['cart_'.$_GET['add']];
    echo '<br/>';
    echo 'info stored<br/>';
*/  
}



//***************************************************


function products()
{
    GLOBAL $link;

    $get ="SELECT id,name,description,price FROM products
    WHERE quantity > 0 ORDER by id ASC";

    if($result=mysqli_query($link,$get))
    {
        echo "Data Selected to be displayed<br/>";
    }
    else
        {
            echo "Error:".mysqli_error($link);
        }


    if(mysqli_num_rows($result)==0)
    {
        echo "There are no products to display!<br/>";
    }
    else
    {
while($get_row=mysqli_fetch_assoc($result))
{
echo '<hr/><br/>';    
echo 'displaying data from database<br/>';
echo '==================================';

echo '<p>'.$get_row['name'].'<br/>'.
$get_row['description'].'<br/>'.
number_format($get_row['price'],2).
'<a href="cart.php?add='.$get_row['id'].'"> Add</a>'.'</p>';
echo '<hr/><br/>';


        }
    }   

}

echo 'outside'.$_SESSION['cart_1'];

?>

</body>
</html>

mini_cart_index.php

<?php require 'cart.php';?>
<!DOCTYPE>
<html>
<head>

</head>

<body>
<?php products() ?>
</body>
</html>

Congratulations! You're no longer a DaniWeb newbie.<br /> <br />
Your DaniWeb account has just been upgraded from newbie status and now you have the ability to take advantage of everything the community has to offer.<br /> <br />
You can now enjoy an advertisement-free DaniWeb by ticking the checkbox to Disable Ads in your profile. You will no longer have to fill out the human verification check when you post. You can also now send unlimited private messages, contribute new code snippets, and tag articles with never-before-used tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.