When I call the following function I don't get any value even though the value was just saved into the database.
Am I making any mistake when I say : $cart=mysql_result($result,0) ?
Is it not supposed to retrieve the last saved value?
Code: Select all
function getCart() {
global $cart;
// if this is a new cart, then create a cart_no using the current time stamp.
// otherwise extract the cart_id from the session variable
if (!$cart)
{
$cart_id = date("d-m-Y-H-i-s");
$sql ="INSERT INTO cart VALUES('".$cart_id."')";
$result=mysql_query($new_cart_id_q);
$cart=mysql_result($result,0);
return $cart;
}
else
{
$cart= $_SESSION['cart'];
}
}