2014-09-06 126 views
-1

你好我即將得到一個PHP錯誤「解析錯誤:語法錯誤,意外的'結束'(T_ENDWHILE)在C:\ wamp \ www \ index.php在32行」任何想法做什麼即時通訊錯誤?解析錯誤,而

<?php 
include ('includes/db_connect.php'); 
$query = $db->prepare("SELECT post_id, title, body FROM posts"); 
$query->execute(); 
$query->bind_result($post_id, $title, $body); 
?> 
<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8" /> 
<meta http-equiv="X-UA-Compatible" content="IE=9" /> 
<!--[if lt IE 9]> 
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></head>script> 
<![endif]--> 
<script scr="http://code.jquery.com/jquery-1.5.min.js"></script> 
</head> 
<style> 
    #container{ 
     margin:auto; 
     width:800px; 
    } 
</style> 
<body> 
<div id="container"> 
    <?php 
     while($query->fetch()); 
    ?> 
    <article> 
     <h2><?php echo $title ?></h2> 
     <p><?php echo $body?></p> 
    </article> 
    <?php endwhile?> 
</div> 
</body> 
</html> 

回答

2

變化:while($query->fetch());

到:while($query->fetch()):

(分號到結腸)