duan39779 2013-06-12 20:01
浏览 11

PHP:在唯一页面中显示博客页面[关闭]

Can anyone tell me why im getting this error with my code:

Parse error: syntax error, unexpected '}' in C:\wamp\www\blogsite\display.php on line 30

Line 30 is the very last {

It all seem right but im missing something i guess

<<?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;
      }
?>
  • 写回答

2条回答 默认 最新

  • douji1877 2013-06-12 20:03
    关注

    You need to use a curly brace rather than a colon here.

    if(mysql_num_rows($result) !=0):
    

    You also need to close the curly brace on the first else before the next if statement from above.

    The last else should also be using a curly brace rather than a colon.

    else {
         echo '<p> UH OOH! THERE IS NO SUCH PAGE IT DOES\'T EXIST </p>'; 
         echo $return;
      }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题