problem resolved (in comments) i am making a project for school and i am getting this error Trying to access array offset on value of type null on this line of code
<div class="user-name"><?php echo $guests["firstName"] ?></div>
it is in this code and i retrieve the information out of a database
foreach((array)$result as $guests)
{
?>
<div class="posts-container">
<div class="post-header">
<div class="user-details">
<div class="user-name"><?php echo $guests["firstName"] ?></div>
<div class="user-email"></div>
</div>
<div class="time"></div>
</div>
<div class="post-message">
<h3></h3>
<p></p>
</div>
</div>
<?php } ?>
people asked for the sql code and the type/structure of $result type/structure: object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(9) ["lengths"]=> NULL ["num_rows"]=> int(5) ["type"]=> int(0) sql/database:
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "guestbook";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, firstName, lastName, email, title, message, URL, showEmail, Date FROM guestbook";
$result = $conn->query($sql);
$conn->close();