我已经建立了一个小博客网站,但每次访问后我都会在日志文件中收到错误。错误显示为PHP Notice: Undefined variable: post_id in /***/***/***/post.php on line 33
我发现它是多个输出($x .= "display"
)的结果,并被告知放入另一个定义它应该有效,但它没有。我的意思是:
<?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>
";
}
?>
现在,在我的页面中,我显示了输出,但上面显示了0
。如何整理原始PHP Notice
?