PHP语法错误在最后一行出现“意外的$ end”

时间:2013-12-14 03:22:55

标签: php

我将这段代码包含在main.php中,并在此代码的最后一行收到语法错误“unexpected $ end”,即使我把}用于while循环。请帮忙

<?php
while($row=mysql_fetch_array($rs))
{
    ?>
    <div class="center_title_bar"><?php echo $row['ProName']?></div>
    <div class="prod_box_big">
        <div class="top_prod_box_big"></div>
        <div class="center_prod_box_big">
            <?php
            echo"<div class='product_img_big'>"; 
                echo"<a href='javascript:popImage('".$row['ProPicture']."','".$row['ProName']."') title='".$row['ProName']."'><img src='".$row['ProPicture']."' alt='' border='0' /></a>";
            echo"</div>";
            echo"<div class='details_big_box'>";
                echo"<div class='product_title_big'>'".$row['ProName']."'</div>";

                echo"<div class='specifications'>'".$row['ProInfo']."'<br />"; 
                    echo"Trạng thái: <span class='blue'>";
                    if($row['ProQuantity'])
                    {
                        echo"Còn hàng";
                    }
                    else {
                        echo"Hết hàng";
                    }
                    echo"</span><br />";
                    echo"Bảo hành: <span class='blue'>".$row[ProWarranty]." tháng</span><br />";
                echo"</div>";

                echo"<div class='prod_price_big'><span class='price'>".number_format($row['ProPrice'],0,',','.')." VND</span></div>";
                    echo'<a href="?options=giohang&action=add&item='.$row[ProID].'" class="addtocart">Thêm vào giỏ</a>';
                    ?> 
                    <a href="location:history.back()" class='compare'>Quay lại</a>
                </div>
            </div>
        </div>
        <div class="bottom_prod_box_big"></div>
}
  

解析错误:语法错误,

意外的$ end

2 个答案:

答案 0 :(得分:5)

如果这是整个脚本,则忘记关闭文件末尾的while循环。

您需要添加:

<?php } ?>

在文件的末尾。

答案 1 :(得分:0)

这是没有错误的脚本

while ($row = mysql_fetch_array($rs)) {
                    ?>
                    <div class="center_title_bar"><?php echo $row['ProName'] ?></div>
                    <div class="prod_box_big">
                        <div class="top_prod_box_big"></div>
                        <div class="center_prod_box_big">
                            <?php
                            echo"<div class='product_img_big'>";
                            echo"<a href='javascript:popImage('" . $row['ProPicture'] . "','" . $row['ProName'] . "') title='" . $row['ProName'] . "'><img src='" . $row['ProPicture'] . "' alt='' border='0' /></a>";
                            echo"</div>";
                            echo"<div class='details_big_box'>";
                            echo"<div class='product_title_big'>'" . $row['ProName'] . "'</div>";

                            echo"<div class='specifications'>'" . $row['ProInfo'] . "'<br />";
                            echo"Trạng thái: <span class='blue'>";
                            if ($row['ProQuantity']) {
                                echo"Còn hàng";
                            } else {
                                echo"Hết hàng";
                            }
                            echo"</span><br />";
                            echo"Bảo hành: <span class='blue'>" . $row[ProWarranty] . " tháng</span><br />";
                            echo"</div>";

                            echo"<div class='prod_price_big'><span class='price'>" . number_format($row['ProPrice'], 0, ',', '.') . " VND</span></div>";
                            echo'<a href="?options=giohang&action=add&item=' . $row[ProID] . '" class="addtocart">Thêm vào giỏ</a>';
                            ?> 
                        <a href="location:history.back()" class='compare'>Quay lại</a>
                    </div>
                </div>
            </div>
            <div class="bottom_prod_box_big"></div>
            <?php
            }