【发布时间】:2013-06-12 20:01:27
【问题描述】:
谁能告诉我为什么我的代码会出现这个错误:
解析错误:语法错误,第 30 行 C:\wamp\www\blogsite\display.php 中出现意外的 '}'
第 30 行是最后一个 {
一切看起来都不错,但我想我错过了一些东西
<<?php
if(isset($_GET['id']) && is_int($_GET['id'])) {
$blogId = (int)$_GET['id'];
$query = "SELECT blog_id, title, date, body FROM content WHERE blog_id='$blogId'";
// run query and get record data and output it
} else {
//code to return all records as list
$dbinfo = "SELECT blog_id, title, date, body FROM content ORDER BY blog_id DESC LIMIT 0, 3";
$result = mysql_query($dbinfo) or die(mysql_error());
$return = '<p><a href="index.php"> Go Back To Content Page</a></p>';
if(mysql_num_rows($result) !=0):
while($row = mysql_fetch_assoc($result)){
echo '<div id="roundedbox"><h2><a href="index.php?id=' . $row['blog_id'].$row['title'] . ' </a></h2>';
echo '<div id="date"><h5><p>' . $row['date'] . '</p></h5></div>';
echo substr('<p>' . $row['body'] . '</p>',0, 90)." .... "." read more</div>";
}
else:
echo '<p> UH OOH! THERE IS NO SUCH PAGE IT DOES\'T EXIST </p>';
echo $return;
}
?>
【问题讨论】:
-
我已经给你一点你的问题,以免你的个人资料被删除,但是你必须注意你的代码编写,因为它是无序的,可能使用 python一小段时间(1 天)你可以写更多的 orderer 代码并且没有这种问题
标签: php mysql database unique blogs