computerworks
Новичок
Оттестил корзину на локалхосте, отлично работает, на хостинге же один из массивов сессии напрочь не хочет становиться массивом
$_SESSION['cart_product_currency'][$product_counter] вот это элемент массива должен при добавлении нового продукта в корзину индексировать валюту товара, которая хранится в базе, но на практике происходит следующее:
Необьяснимая ошибка находится именно в этой строке:
$_SESSION['cart_product_currency'][$product_counter]=$cart_product_currency;
и сказывается именно на хостинге.
PHP:
if($action=="add_product_to_cart") {
$cart_product_query=mysql_query("SELECT price, product_currency FROM products WHERE product_id=$product_id");
while($cart_product_data=mysql_fetch_assoc($cart_product_query)){
$cart_price=$cart_product_data['price'];
$cart_product_currency=$cart_product_data['product_currency'];
}
$_SESSION['product_counter']++;
$product_counter=$_SESSION['product_counter'];
$_SESSION['cart_product_id'][$product_counter]=$product_id;
$_SESSION['cart_product_count'][$product_counter]=1;//$_REQUEST['cart_product_count'];
$_SESSION['cart_product_cost'][$product_counter]=$cart_price;
$_SESSION['cart_product_currency'][$product_counter]=$cart_product_currency;
header("Location: ".$_SERVER['HTTP_REFERER']);
die();
}
PHP:
Array
(
[product_counter] => 2
[cart_product_id] => Array
(
[1] => 8
[2] => 6
)
[cart_product_count] => Array
(
[1] => 1
[2] => 1
)
[cart_product_cost] => Array
(
[1] => 2930.4
[2] => 1601.50
)
[cart_product_currency] => rur
)
$_SESSION['cart_product_currency'][$product_counter]=$cart_product_currency;
и сказывается именно на хостинге.