dstjh46606 2015-01-07 08:51
浏览 32

我的echo语句不会在html行中显示

This is my code. I'm trying to print the comments on my site. The query and everything works since I tried it in an empty project but here it doesn't echo. The comments update in the database but they just don't show. What am I missing?

<h1>Leave a comment below!</h1>
<?php

$find_comments = mysql_query("SELECT * FROM comments");

if ($find_comments) {  
    while ($row = mysql_fetch_assoc($find_comments)) {
        $comment_name = $row['name'];
        $comment = $row['comment']; 
        echo "<p>'$comment_name' - '$comment'</p>"; 
    }
}

if(isset($_GET['error'])) {
    echo "<p>100 per limit";
}

?>
<form action="post_comments.php" method="post">
    <p>Your Name: </p>
    <input  type="text" name="name" size="40" maxlength="30" placeholder="Enter name..." </input><br><p>
    <p>Your Email: </p>
    <input  type="text" name="email" size="40" maxlength="30" placeholder="Enter email..." </input><br><p>
    <p>Your comment: </p>
    <textarea  type="text" name="comment" cols="50" rows="10" placeholder="Enter comment..."></textarea><br><p>      
    <input  type="submit" name="submit" value="Submit comment!" ></input>
</form>
  • 写回答

3条回答 默认 最新

  • duandie5707 2015-01-07 08:56
    关注

    Your variable name is in single quote, it must me concat or place in double quote..

    For Ex

                echo "<p>$comment_name-$comment</p>"; 
    

    or

                echo "<p>".$comment_name."-".$comment</p>";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答