- Registriert
- 09.12.06
- Beiträge
- 363
Hallo! Ich habe ein Problem mit einem PHP-Script. Ich bekomme eine "Header already sent"-Fehlermeldung, da innerhalb der Datei eine Variable deklariert ist. Es handelt sich dabei um folgenden Syntax:
Wie man an der eckigen Klammer sieht, bezieht sich dieser Abschnitt auf den folgenden Inhalt. Somit kann ich die Variable nicht im Header deklarieren - aber wenn ich sie da an der Stelle stehen lasse, bekomme ich weiterhin die Fehlermeldung. Was kann ich da tun?
Hier der komplette Code der Datei.
Code:
for ($i = 0; $i < $numItem; $i++) {
extract($cartContent[$i]);
Hier der komplette Code der Datei.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<?
require_once 'library/config.php';
require_once 'library/cart-functions.php';
$subTotal = 0;
$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];
$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
$pdId = (isset($_GET['p']) && $_GET['p'] != '') ? $_GET['p'] : 0;
$action = (isset($_GET['action']) && $_GET['action'] != '') ? $_GET['action'] : 'view';
switch ($action) {
case 'add' :
addToCart();
break;
case 'update' :
updateCart();
break;
case 'delete' :
deleteFromCart();
break;
case 'view' :
}
$cartContent = getCartContent();
$numItem = count($cartContent);
$pageTitle = 'Shopping Cart';
require_once 'include/header.php';
$root = '../../';
$lang = 'de';
$name = 'cart';
include("$root/inc/meta.inc.php");
?>
<link rel="stylesheet" type="text/css" href="<? echo $root ?>inc/style.css">
</head>
<body>
<?
# INCLUDE SITESTRUCTURE TOP
include("$root/inc/sitestructure_top.inc.php");
#########################################
########### START BANDS INDEX ###########
#########################################
// show the error message ( if we have any )
displayError();
if ($numItem > 0 ) {
?>
<form action="<?php echo $_SERVER['PHP_SELF'] . "?action=update"; ?>" method="post" name="frmCart" id="frmCart">
<table width="620" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">
<tr class="entryTableHeader">
<td colspan="2" align="center">Item</td>
<td align="center">Unit Price</td>
<td width="75" align="center">Quantity</td>
<td align="center">Total</td>
<td width="75" align="center"> </td>
</tr>
<?
[COLOR=Blue] for ($i = 0; $i < $numItem; $i++) {
extract($cartContent[$i]);[/COLOR]
?>
<tr class="content">
<td width="80" align="center"><a href="<?php echo $productUrl; ?>"><img src="<?php echo $pd_thumbnail; ?>" border="0"></a></td>
<td><a href="<?php echo $productUrl; ?>"><?php echo $pd_name; ?></a></td>
<td align="right"><?php echo displayAmount($pd_price); ?></td>
<td width="75"><input name="txtQty[]" type="text" id="txtQty[]" size="5" value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);">
<input name="hidCartId[]" type="hidden" value="<?php echo $ct_id; ?>">
<input name="hidProductId[]" type="hidden" value="<?php echo $pd_id; ?>">
</td>
<td align="right"><?php echo displayAmount($pd_price * $ct_qty); ?></td>
<td width="75" align="center"> <input name="btnDelete" type="button" id="btnDelete" value="Delete" onClick="window.location.href='<?php echo $_SERVER['PHP_SELF'] . "?action=delete&cid=$ct_id"; ?>';" class="box">
</td>
</tr>
<?php
}
?>
<tr class="content">
<td colspan="4" align="right">Sub-total</td>
<td align="right"><?php echo displayAmount($subTotal); ?></td>
<td width="75" align="center"> </td>
</tr>
<tr class="content">
<td colspan="4" align="right">Shipping </td>
<td align="right"><?php echo displayAmount($shopConfig['shippingCost']); ?></td>
<td width="75" align="center"> </td>
</tr>
<tr class="content">
<td colspan="4" align="right">Total </td>
<td align="right"><?php echo displayAmount($subTotal + $shopConfig['shippingCost']); ?></td>
<td width="75" align="center"> </td>
</tr>
<tr class="content">
<td colspan="5" align="right"> </td>
<td width="75" align="center">
<input name="btnUpdate" type="submit" id="btnUpdate" value="Update Cart" class="box"></td>
</tr>
</table>
</form>
<?php
} else {
?>
<p> </p><table width="550" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td><p align="center">You shopping cart is empty</p>
<p>If you find you are unable to add anything to your cart, please ensure that
your internet browser has cookies enabled and that any other security software
is not blocking your shopping session.</p></td>
</tr>
</table>
<?php
}
?>
<table width="550" border="0" align="center" cellpadding="10" cellspacing="0">
<tr align="center">
<td><input name="btnContinue" type="button" id="btnContinue" value="<< Continue Shopping" onClick="window.location.href='index.php';" class="box"></td>
<?php
if ($numItem > 0) {
?>
<td><input name="btnCheckout" type="button" id="btnCheckout" value="Proceed To Checkout >>" onClick="window.location.href='checkout.php?step=1';" class="box"></td>
<?php
}
?>
</tr>
</table>
<?
#########################################
############ END BANDS INDEX ############
#########################################
# INCLUDE SITESTRUCTURE BOTTOM
include("$root/inc/sitestructure_bottom.inc.php");
?>
</body>
</html>