Cart page not producing any html


#1

Since this forum has been so helpful I thought I’d try again. :-?

I have a cart page that is persistent and uses cookies that are stored in the database. When I click on the submit button on my product page I get this source code:

A blank page!

Here is the form tag on the products page:

">

And here is the CART.PHP file:

[php]<?php
include("…/…/Connections/db_login.php");

switch($_GET["action"]):
case "add_item":
AddItem($_GET["ID"], $_GET["SIZE"], $_GET["OPT"], $_GET["QTY"]);
ShowCart();
break;
case "update_item":
UpdateItem($_GET["ID"], $_GET["QTY"]);
ShowCart();
break;
case "remove_item":
RemoveItem($_GET["ID"]);
ShowCart();
break;
default:
ShowCart();
endswitch;

function AddItem($id, $size, $options, $quantity)
{
// Will check whether or not this item
// already exists in the cart table.
// If it does, the UpdateItem function
// will be called instead
global $hostname_db_products, $username_db_products, $password_db_products, $database_db_products;
// Get a connection to the database
$cxn = @ConnectToDb($hostname_db_products, $username_db_products, $password_db_products, $database_db_products);
// Check if this item already exists in the users cart table
$result = mysql_query(“select count(*) from ORDERS where COOKIEID = '” . GetCartId() . “’ and ITEMID = $id and SIZE = $size and OPTIONS = $options”);
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn’t exist in the users cart,
// we will add it with an insert query
@mysql_query(“insert into ORDERS(COOKIEID, ITEMID, PRODID, SIZE, OPTIONS, QUANTITY, PRICE, LASTDATEACCESS) values(’” . GetCartId() . “’, $itemid, ,$prodid, $size, $options, $quantity, $price, $date)”);
}
else
{
// This item already exists in the users cart,
// we will update it instead
UpdateItem($id, $qty);
}
}
function UpdateItem($id, $qty)
{
// Updates the quantity of an item in the users cart.
// If the qutnaity is zero, then RemoveItem will be
// called instead
global $hostname_db_products, $username_db_products, $password_db_products, $database_db_products;
// Get a connection to the database
$cxn = @ConnectToDb($hostname_db_products, $username_db_products, $password_db_products, $database_db_products);
if($QUANTITY == 0)
{
// Remove the item from the users cart
RemoveItem($id);
}
else
{
mysql_query(“update ORDERS set QUANTITY = $quantity where COOKIEID = '” . GetCartId() . “’ and ID = $id and SIZE = $size and OPTIONS = $options”);
}
}
function RemoveItem($id)
{
// Uses an SQL delete statement to remove an item from
// the users cart
global $hostname_db_products, $username_db_products, $password_db_products, $database_db_products;
// Get a connection to the database
$cxn = @ConnectToDb($hostname_db_products, $username_db_products, $password_db_products, $database_db_products);
mysql_query(“delete from ORDERS where COOKIEID = '” . GetCartId() . “’ and ID = $id”);
}
function ShowCart()
{
// Gets each item from the cart table and display them in
// a tabulated format, as well as a final total for the cart
global $hostname_db_products, $username_db_products, $password_db_products, $database_db_products;
// Get a connection to the database
$cxn = @ConnectToDb($hostname_db_products, $username_db_products, $password_db_products, $database_db_products);
$totalCost = 0;
$result = mysql_query(“select PRODID, SIZE, OPTIONS, QUANTITY, PRICE from ORDERS where COOKIEID = '” . GetCartId() . “’ order by items.itemName asc”) or die(mysql_error());
?>

Your Shopping Cart

Your Shopping Cart

Delete Item?
Picture Name
Size
Options
Quantity
Price
<?php echo $row["PRODID"]; ?> <?php echo $row["SIZE"]; ?> <?php echo $row["OPTIONS"]; ?> " onChange="UpdateQty(this)"> <?php for($i = 1; $i <= 20; $i++) { echo "" . $i . ""; } ?> $<?php echo number_format($row["itemPrice"], 2, ".", ","); ?>
        Total: $<?php echo number_format($totalCost, 2, ".", ","); ?>

 

<?php } ?>[/php]

This is the last page I need working to get my cart functioning and I have been pulling my hair out trying to get it to work.

Any ideas?


#2

OK so what is the problem? that you are getting a blank page? what should you be getting instead? What have you done to find out where the problem is and what have you tried to correct the problem?