<?php
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Section 1 (if user attempts to add something to the cart from the product page)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (isset($_POST['pid'])) {
$pid = $_POST['pid'];
$wasFound = false;
$i = 0;
// If the cart session variable is not set or cart array is empty
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
// RUN IF THE CART IS EMPTY OR NOT SET
$_SESSION["cart_array"] = array(0 => array("item_id" => $pid, "quantity" => 1));
} else {
// RUN IF THE CART HAS AT LEAST ONE ITEM IN IT
foreach ($_SESSION["cart_array"] as $each_item) {
$i++;
while (list($key, $value) = each($each_item)) {
if ($key == "item_id" && $value == $pid) {
// That item is in cart already so let's adjust its quantity using array_splice()
array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1)));
$wasFound = true;
} // close if condition
} // close while loop
} // close foreach loop
if ($wasFound == false) {
array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1));
}
}
header("location: http://www.hirelogo.com/cart.php");
exit();
}
?>
내가 받고있는 오류를 이해하는 데 문제가 있습니다. 그게 도움이된다면 최근에 PHP의 최신 버전으로 VPS로 전환했습니다. 이 많이 감사 이해헤더 오류 수정
header("location: http://www.hirelogo.com/cart.php ");
도움이되는
Warning: Cannot modify header information - headers already sent by (output started at /home/hirelogo/public_html/cart.php:5) in /home/hirelogo/public_html/cart.php on line 40
라인 (40) :이 오류입니다. 또 다른 메모. 이 문제는 전환하기 전에 발생하지 않았습니다.
온라인 5는 무엇입니까? – Scuzzy
ob_end_flush(); 나는 그 문제를 완화 시키려고 노력했다. – Chris
' php' 전에 아무것도 없는지 확인하십시오. 코드를 실행하기 전에 전송되기 때문에. – Barmar