asked on
Warning: mysqli_connect(): (28000/1045): Access denied for user 'HarrisK'@'ip-107-180-46-230.ip.secureserver.net' (using password: YES) in /home/hfll4ovlkhjz/public_html/config/db_connect.php on line 3
Connection error: Access denied for user 'HarrisK'@'ip-107-180-46-230.ip.secureserver.net' (using password: YES)
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/hfll4ovlkhjz/public_html/index.php on line 6
Fatal error: Uncaught Error: Call to undefined function mysqli_fetch_all() in /home/hfll4ovlkhjz/public_html/index.php:8 Stack trace: #0 {main} thrown in /home/hfll4ovlkhjz/public_html/index.php on line 8
<?php
include('config/db_connect.php');
// write query for all pizzas
$sql = 'SELECT title, ingredients, id FROM pizzas ORDER BY created_at';
// get the result set (set of rows)
$result = mysqli_query($conn, $sql);
// fetch the resulting rows as an array
$pizzas = mysqli_fetch_all($result, MYSQLI_ASSOC);
// free the $result from memory (good practise)
mysqli_free_result($result);
// close connection
mysqli_close($conn);
?>
<!DOCTYPE html>
<html>
<?php include('templates/header.php'); ?>
<h4 class="center grey-text">Pizzas!</h4>
<div class="container">
<div class="row">
<?php foreach($pizzas as $pizza): ?>
<div class="col s6 m4">
<div class="card z-depth-0">
<img src="img/pizza.svg"class="pizza">
<div class="card-content center">
<h6><?php echo htmlspecialchars($pizza['title']); ?></h6>
<ul class="grey-text">
<?php foreach(explode(',', $pizza['ingredients']) as $ing): ?>
<li><?php echo htmlspecialchars($ing); ?></li>
<?php endforeach; ?>
</ul>
</div>
<div class="card-action right-align">
<a class="brand-text" href="details.php?id=<?php echo $pizza['id'] ?>">more info</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php include('templates/footer.php'); ?>
</html>