<?php
error_reporting(E_ALL ^ E_NOTICE);
require("global.php");
 $note_id = $_GET['id']; //得到超链接中参数
 $sql = "select note.*,noan.* from tb_note as note left join tb_note_answer as noan on note.note_id = noan.noan_note_id";
 if($note_id!="-1"){
 $sql.=" where note.note_id= ".$note_id;
 }
//最后加上排序语句,按note_time降序,按noan_time降序
$sql .= " order by note.note_time desc";
$DB->query($sql);
$note = $DB->get_rows_array($sql);
         echo mysql_error();?>
出错的地方是$note_id没有值。

解决方案 »

  1.   

    看URL地址里包含不包含http://xxx.xxx.com/xxx.php?id=xx这样的结构。如果有一般不会出现这个情况。
    要不就是数据类型不对。参与SQL的要求是整数,结果传递了一个字符串。
      

  2.   

    把$sql这个字符串打出来看看,$_GET['id']也应该打一下,也许参数根本没传过来
      

  3.   


    $note_id = empty($_GET['id']) ? NULL : $_GET['id'];
    echo $note_id;