gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 01:36:31 25 4
gpt4 key购买 nike

这是我的代码。我正在尝试打印我网站上的评论。查询和一切正常,因为我在一个空项目中尝试过,但在这里它没有回应。评论在数据库中更新,但它们只是不显示。我错过了什么?

<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>

最佳答案

你的变量名是用单引号引起来的,我必须用双引号连接或放置..

对于前者

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

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

关于php - 我的 echo 语句不会显示在 html 行中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27815562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com