So I wanted to add in a test whether cookies are enabled for my website. and Some reason now the page won't load even after I removed it from the code.
The errors I'm getting.
Warning: require_once(../system/init.php): failed to open stream: No such file or directory in /index.php on line 2
Fatal error: require_once(): Failed opening required '../system/init.php' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /index.php on line 2
Here is code with script still in
<?php
require_once 'system/init.php';
include 'includes/head.php';
include 'includes/navigation.php';
include 'includes/headerfull.php';
include 'includes/leftbar.php';
$sql= "SELECT * FROM products WHERE featured = 1";
$featured = $db->query($sql);
?>
<!-- main content -->
<div id="maincontent" class="col-md-8" style=" ">
<div class="row">
<h2 class="text-center">Feature Products</h2>
<?php while($product = mysqli_fetch_assoc($featured)) : ?>
<div class="col-sm-3 text-center">
<h4><?= $product['title']; ?></h4>
<img src="<?= $product['image']; ?>" alt="<?= $product['title']; ?>" class="img-thumb"/>
<p class="price">Our Price: <?= $product['price']; ?></p>
<button type="button" class="btn btn-sm btn-success" onclick="detailsmodal(<?= $product['id']; ?>)">Details</button>
</div>
<?php endwhile; ?>
</div>
</div>
<script type="text/javascript">
if (navigator.cookieEnabled) return true;
// set and read cookie
document.cookie = "cookietest=1";
var ret = document.cookie.indexOf("cookietest=") != -1;
// delete cookie
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
return ret;
</script>
<?php
include 'includes/rightbar.php';
include 'includes/footer.php';
?>
edit: The possible duplicate did not work. The code on the page worked fine before I added what is in the tags. after I tried them and they did not work I reverted back to the working copy and it still does not work.
Edit 2:
So I really have no idea what happened now. After searching and looking for answers I refresh one more time and now its magically working? Can someone explain this? I had refreshed 20+ times by that point becuase I wondered if the jscript messed up my cookie.