簡體   English   中英

意外令牌:關閉div標簽

[英]Unexpected token: closing div tag

我有以下代碼。 當我運行它時,我在控制台中收到一條錯誤消息,提示有一個意外的標記-結束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>
 echo '<button class="btn btn-light btn-xl sr-button" onclick="window.location.href="/editDisplay.php?id='. $recipeID . '">Edit</button>';

在這里看:

onclick="window.location.href="/editDisplay.php?id='. $recipeID . '"

您的onclick屬性沒有關閉“”,只有window.location.href沒有。這可能是問題所在,因為通常情況下,由於引號未正確關閉,它會選擇結尾的div。

那是因為您的div標簽短了一個。 我花了2秒鍾的時間才能找到答案,方法是將您的代碼粘貼到Notepad ++中,然后單擊每個div以查看它是否有閉合對。 請注意,這樣您就可以解決html標簽的問題了:)

結束

[英]Closing </div> Tag Is Being Outputted To Early In A While Loop - PHP

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM