0

我该如何解决Notice: Undefined index: topic_creator in C:\wamp\www\forum\view_category.php on line 313我从这个错误中得到两个。我确实在一个页面上读到,将@放在 $topic_creator 前面可能会有所帮助,但我没有。我找不到说明如何修复它的地方,所以请帮助我。这是我的代码

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>&nbsp;".$title."</div></a>
        <div class='info'><i class='icon-comments icon-1'></i>&nbsp;".topicreplies($cid, $tid)." Comments&nbsp; &nbsp; &nbsp;<i class='icon-user icon-1'>
        &nbsp;</i>".$last2_user."&nbsp; ".$last_user."
4

0 回答 0