PHP works locally, but doesn't work on 000webhost


My site is working as intended locally, but when I uploaded the files to 000webhost, it is not working.

The part that is not working is when you click on the button to add the item to the cart an alert should appear saying “Item has been added to cart” and it should add the item to the shopping cart.

It is not doing either of these things and I cannot figure out why.

My site is

Please let me know if you need more information.

Here is the code I’m using for this particular section:

if(isset($_POST[“add_to_cart”])) {
if(isset($_SESSION[“shopping_cart”])) {
$item_array_id = array_column($_SESSION[“shopping_cart”], “item_id”);
if(!in_array($_GET[“id”], $item_array_id)) {
$count = count($_SESSION[“shopping_cart”]);
$item_array = array(
‘item_id’ => $_GET[“id”],
‘item_name’ => $_POST[“hidden_name”],
‘item_price’ => $_POST[“hidden_price”],
‘item_quantity’ => $_POST[“quantity”]
$_SESSION[“shopping_cart”][$count] = $item_array;
echo ‘<script>alert("Item added to cart!")</script>’;
echo ‘<script>alert("Item already added to cart, please remove item from cart before adjusting quantity.")</script>’;
echo ‘<script>window.location="index.php"</script>’;
} else {
$item_array = array(
‘item_id’ => $_GET[“id”],
‘item_name’ => $_POST[“hidden_name”],
‘item_price’ => $_POST[“hidden_price”],
‘item_quantity’ => $_POST[“quantity”]
$_SESSION[“shopping_cart”][0] = $item_array;

  <div class="w3-quarter" style="margin-top: 16px;">
  	<div class="w3-row-padding">
  	<form method="post" style="text-align: center;" action="index.php?action=add&id=<?php echo $row["id"]; ?>">
  		 <div style="border:1px solid #333; background-color:#f1f1f1; border-radius:5px; padding:16px;" align="center">
  					<img src="<?php echo $row["image"]; ?>" /><br />
  					<h4 class="text-info"><?php echo $row["name"]; ?></h4>
  					<h4 class="text-danger">$<?php echo $row["price"]; ?></h4>
  					<input type="number" name="quantity" style="width: 50%;" class="form-control" value="1" min="1" />
  					<input type="hidden" name="hidden_name" value="<?php echo $row["name"]; ?>" />
  					<input type="hidden" name="hidden_price" value="<?php echo $row["price"]; ?>" />
  					<input type="submit" name="add_to_cart" style="margin-top:5px;" class="btn btn-success" value="Add to Cart" />


Can you try lowering your PHP version to 5.6?


I lowered the PHP version to 5.6 and it is still not working. I forgot to mention that this all worked before and then I made some changes to where the shopping cart is displayed on another page and added some alerts and it stopped working on this site.


Hi @ChaCol
Can you revert those changes?


Are you sure you have called the session_start(); at the start of the php code ?


“Your website” > Settings > General: Show Errors -> Enable

Refresh the page and analyze the errors


Warning: session_start(): open(/storage/ssd4/755/3098755/tmp/sess_smnaih3l847qs5ug5vtlfkcg62, O_RDWR) failed: No such file or directory (2) in /storage/ssd4/755/3098755/public_html/index.php on line 3

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /storage/ssd4/755/3098755/public_html/index.php:3) in /storage/ssd4/755/3098755/public_html/index.php on line 3

Warning: Unknown: open(/storage/ssd4/755/3098755/tmp/sess_smnaih3l847qs5ug5vtlfkcg62, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/storage/ssd4/755/3098755/tmp) in Unknown on line 0


I was able to fix it by resetting file permissions.