0

I have that code included to the main.php and received syntax error “unexpected $end” at last line of this code even I put the } for the while loop. Please help

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

Parse error: syntax error, unexpected $end in

5
  • The first error that pops out to me is <?php echo $row['ProName']?>... you're missing a semicolon. There might be more errors; I stopped looking after that one. Commented Dec 14, 2013 at 3:24
  • you are missing the } to close the while loop Commented Dec 14, 2013 at 3:25
  • But even I tried putting the last } to close the loop, I still have Parse error: syntax error, unexpected $end in Commented Dec 14, 2013 at 3:30
  • Almost, just updated my answer, see below. Commented Dec 14, 2013 at 3:31
  • Please open PHP tag before } and close PHP tag after } -- <?php } ?> Commented Dec 14, 2013 at 4:57

2 Answers 2

5

If this is the whole script, you forgot to close the while loop from the begining, at the end of the file.

You need to add:

<?php } ?>

at the end of the file.

Sign up to request clarification or add additional context in comments.

4 Comments

Yeah, you're so brilliant.
Hm.. I can't find any other error in this script.. are you sure the error comes from this script?
Mr Greenish, can you help me analyze this code line: echo"<a href='javascript:popImage('".$row['ProPicture']."','".$row['ProName']."') title='".$row['ProName']."'><img src='".$row['ProPicture']."' alt='' border='0' /></a>"; I just get back <a href='javascript:popImage( in my browser
The problem is, that you use ' to set href='' and inside href you use the same ' to define popImage('','') parameters. Try using \" instead of ' for html attributes like href.
0

this is the script without error

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
            }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.