我如何修复Notice: Undefined index: topic_creator in C:\wamp\www\forum\view_category.php on line 313
我得到两个错误。
我确实在一个页面上看到,将@top_creator放在$ infront可能会有所帮助,但我仍然留意。我找不到一个说明如何修理的地方,所以请帮助我。
这是我的代码
include_once("connect.php");
$sql = "SELECT id FROM categories WHERE id='".$cid."' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) == 1) {
$sql2 = "SELECT * FROM topics WHERE category_id='".$cid."' ORDER BY topic_reply_date DESC";
$res2 = mysql_query($sql2) or die(mysql_error());
if (mysql_num_rows($res2) > 0) {
while ($row = mysql_fetch_assoc($res)) {
**Line 313** if($row['topic_last_user']== "") { $last_user = getusername($row['topic_creator']); } else { $last_user = getusername($row['topic_creator']); }
$topics .="
<li class='category'><div class='left_cat'>
<a class='underline' href='view_topic.php?cid=".$cid."&tid=".$tid."'>
<div class='title'><i class='icon-comment'></i> ".$title."</div></a>
<div class='info'><i class='icon-comments icon-1'></i> ".topicreplies($cid, $tid)." Comments <i class='icon-user icon-1'>
</i>".$last2_user." ".$last_user."