每次尝试使用mysql语句时都会出现php语法错误

时间:2013-08-11 10:32:30

标签: php

我有这样的声明:

while ($row= mysql_fetch_assoc($sql)){      

  $comments .= "<fieldset> User Says : <div class='each_comment'>  <small><em> ".convert($row['comment_date'])." </em></small><br />".$row['comment']." 

  <input type='text' class='reply' comments_id='{$row['comments_id']}' />

      </div></fieldset>  </br>"; 
}

我想要做的就是插入这一行:

 $reply_query = mysql_query("SELECT reply_id, reply FROM comments_reply WHERE comments_id='$comments_id' ");  

以上输入和$评论。问题是,无论我尝试过什么都会导致错误。这就是我到目前为止所做的:

while ($row= mysql_fetch_assoc($sql)){      

  $comments .= "<fieldset> User Says : <div class='each_comment'>  <small><em> ".convert($row['comment_date'])." </em></small><br />".$row['comment']." 

      $reply_query = mysql_query("SELECT reply_id, reply FROM comments_reply WHERE comments_id='$comments_id' ");

  <input type='text' class='reply' comments_id='{$row['comments_id']}' />

      </div></fieldset>  </br>"; 
}

可以在那里使用吗?知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

while ($row= mysql_fetch_assoc($sql)) {
    $comments .= "<fieldset> User Says : <div class='each_comment'>  <small><em> ".convert($row['comment_date'])." </em></small><br />".$row['comment'];
    $reply_query = mysql_query("SELECT reply_id, reply FROM comments_reply WHERE comments_id='$comments_id' ");
    while ($row2= mysql_fetch_assoc($reply_query)) {
        // do what you want with the reply results
    }
    $comments .= "<input type='text' class='reply' comments_id='{$row['comments_id']}' />
    </div></fieldset>  </br>"; 
}