我從StackOverflow嘗試了很多關於這個錯誤的東西,但沒有運氣。注意:未定義的索引:comment_author
我嘗試顯示評論回覆。顯示回覆評論以及發佈日期和時間,但未發佈發佈回覆的作者。
與錯誤的頁面是comments.php
上線$com_name = $row['comment_author'];
的代碼是:
<?php
$get_id = $_GET['post_id'];
$get_com = "select * from comments where post_id='$get_id'";
$run_com = mysqli_query($con, $get_com);
while($row=mysqli_fetch_array($run_com)){
$com = $row['comment'];
$com_name = $row['comment_author'];
$date = $row['date'];
echo "
<div id='comment'>
<h3>$com_name</h3><i>Said</i> on $date
<p>$com</p>
</div>
";
}
?>
希望弄清楚這個錯誤。
謝謝,最好的問候。
哪些列名稱? –
我會把錢放在'comment_author'不是列名的事實上。 – Matt
我很確定,如果你做了'var_dump($ row)',就不會有'$ row ['comment_author']'索引。 – Asur