Exception or error:
Today i’m facing the unnessesary error in my code. I had tried the codes are working fine at localhost(XAMPP) but when i had uploaded it to live server there was i’m getting error
My codes : –
HTML :
<table class="table" id="myParoCart"></table>
Ajax (updateMyCart.php) :
session_start();
if(!empty($_SESSION["shopping_cart"])){
include "inc/config.php";
$sl = 1;
$totalPrice=0;
foreach($_SESSION["shopping_cart"] as $keys => $values){
$query=mysqli_query($me, "SELECT * FROM `pro_item` WHERE `id`='".$values['item_id']."'");
$proDetails=mysqli_fetch_assoc($query);
$totalPrice=$totalPrice+($proDetails['price']*$values['item_quantity']);
}
$shippingCharge=0;
if ($totalPrice>299) {
$shippingCharge=0;
}else{
$shippingCharge=50;
}
$discount=0;
$grandTotal=0;
$grandTotal=$totalPrice+$shippingCharge-$discount;
if ($shippingCharge=='0') {
$shippingCharge='Free Shipping';
}else{
$shippingCharge="₹".$shippingCharge;
}
echo ' <tbody>
<tr>
<th>Sub Total : </th>
<td><span class="price">₹'.$totalPrice.'</span></td>
</tr>
<tr>
<th> Shipping Charge:</th>
<td><span class="price">'.$shippingCharge.'</span></td>
</tr>
<!--tr>
<th> Discount:</th>
<td><span class="price">-₹'.$discount.'</span></td>
</tr-->
<tr>
<th class="cart_btn_cntnt"> Grand Total :</th>
<td><span class="cart_btn_cntnt_clr">₹'.$grandTotal.'</span> </td>
</tr>
</tbody>';
}else{
echo "Empty Cart";
}
?>
Script (jQuery) :
function updateParoCart(){
$('#myParoCart').load('updateMyCart.php',function () {
//$(this).unwrap();
});
}
updateParoCart(); // This will run on page load
setInterval(function(){
updateParoCart() // this will run after every 5 seconds
}, 100);
When i had run this code at my localhost (XAMPP) there are i’m not facing any error but after uploading it to my server i’m getting error that is i’m getting empty $_SESSION['shopping_cart']
WHERE i had used $_SESSION['shopping_cart']
on my HTML file and that working fine at both place (Live & Local).
I had Search on Internet also here and i had found some solution like settings for php.ini files but can’t understand how to apply that.
How to solve: