Hi,
I am developing a shopping cart for my site but have hit a problem. The problem I have is when I try to display the items in my shopping cart. I have checked my database table and the items I am adding from my product page are going in to the 'cart' table but are not displaying in my cartbooks.php script.
I am receiving no error message just a blank shopping cart.
The problem appears to be from my GetCartId function. The GetCartId() function is as follows in db.php:
function GetCartId()
{
if(isset($COOKIE["cartId"]))
{
return $COOKIE["cartId"];
}
else
{
session_start();
setcookie("cartId", session_id(), time() + ((3600 24) 30));
return session_id();
}
}
The following script from cartbooks.php calls the GetCartId function to capture the cartId to cross reference to the 'cart1' table and display the items matching the cartId:
$result = mysql_query("select * from cart1 inner join items on cart1.itemId = items.itemId where cart1.cookieId = '" . GetCartId() . "' order by items.itemName asc");
The reason why I believe it is the GetCartId() function is because if I change the '".GetCartId()."' (in cartbooks.php just above) to '"81Fb9H2"' (an assigned cartId in the 'cart1' table) it displays the items perfectly.
Is there anything on my hosts server which could cause this error as I have tried the same script on a free PHP host and the cart worked fine - I don't think the script has changed but the free PHP host website has been down for a few days and I don't know if it is down for good.
Is there anything in my script that looks strange ?????
I am tearing my hair out !!
Thanks in advance for your help,
Geoman