php - 意外标记:关闭 div 标记
问题描述
我有以下代码。当我运行它时,我在控制台中收到一条错误消息,指出有一个意外的标记 - 结束 div 标记。我不确定为什么。当 if 语句返回 false 时,没有问题。
<div class="container text-center">
<div class="floatLeft">
<br><br>
<h2 class="mb-4 text-white"><? echo $recipe ?></h2>
<h3> <?echo $description ?> </h3> <br>
<h3 class="mb-4 text-white"><? echo 'Duration: '. $duration ?></h3>
<?php
$query800 = $db->prepare("select * from user_cookbook where userID=:userID");
$dbParams8 = array('userID'=>$thisUser);
$query800->execute($dbParams8);
while ($dbRow8 = $query800->fetch(PDO::FETCH_ASSOC)){
$recipeIDarray[]=$dbRow8['recipeID'];
}
if (in_array($recipeID, $recipeIDarray)){
echo '<button class="btn btn-light btn-xl sr-button" onclick="window.location.href="/editDisplay.php?id='. $recipeID . '">Edit</button>';
}
?>
</div>
解决方案
那是因为你有一个短的结束 div-tag。通过将代码粘贴到 Notepad++ 中并单击每个 div 以查看它是否有闭合对,我花了 2 秒钟的时间来找出答案。只是提醒一下,这样您就知道如何排除 html 标签的问题了 :)
推荐阅读
- java - 如何使用集合从 arrayList 调用第二大数字
- javascript - 错误使用 Javascript setInterval()
- apache - 如何在 Apache 中处理(REAL)空格?
- javascript - 如何从表格中使用 Google 脚本获取值(),以便日期值匹配
- r - H2O h2o.stackedEnsemble 中的错误:“不知道如何确定多项分类器的分布”
- oauth-2.0 - 如何使用身份验证服务器颁发的 JWT 令牌来允许访问另一个应用程序?
- makefile - 允许用户覆盖 CFLAGS、CXXFLAGS 和好友
- swift - Travis swift库编译错误
- swift - 将 3D 模型及其节点导入 Xcode
- java - 通过 maven 将环境变量传递给 config.properties 文件