<?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没有值。
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没有值。
要不就是数据类型不对。参与SQL的要求是整数,结果传递了一个字符串。
$note_id = empty($_GET['id']) ? NULL : $_GET['id'];
echo $note_id;