I've built a little blog website but I keep getting errors in the log file after every visit. The error reads, PHP Notice: Undefined variable: post_id in /***/***/***/post.php on line 33
I've found that it's a result of having multiple outputs ($x .= "display"
) and was told that putting in another one to define it should work, but it doesn't. What I mean is:
<?php
$display_posts = "0";
?>
<?php
$posts_sql = "SELECT * FROM posts ORDER BY added DESC LIMIT 10";
$posts_res = mysqli_query($con, $posts_sql);
while($post = mysqli_fetch_assoc($posts_res)){
$post_id = $post["id"];
etc
etc
$display_posts .= "
<div class=\"block\"></div>
";
}
?>
Now in my page I get the output displayed but a 0
is shown above it. How do I sort out the original PHP Notice
?