留言板不显示评论的修改造成首页报错:

2016-07-07 16:08 来源:www.chinab4c.com 作者:ecshop专家

请问可有哪位大侠知道,小弟愁死了

回答:
  1. $sql = "SELECT COUNT(*) FROM " .$GLOBALS['ecs']->table('comment')." WHERE STATUS =1 AND comment_type =0 ";
  2. //$record_count = $db->getOne($sql);
  3. $sql = "SELECT COUNT(*) FROM " .$GLOBALS['ecs']->table('feedback')." WHERE `msg_area`='1' AND `msg_status` = '1' ";
  4. $record_count = $db->getOne($sql);


  5. if($mysql_ver > '3.2.3')
  6. {
  7. //$sql = "(SELECT 'comment' AS tablename,comment_id AS ID, content AS msg_content, null AS msg_title, add_time AS msg_time, id_value AS id_value, comment_rank AS comment_rank, null AS message_img, user_name AS user_name, '6' AS msg_type ";
  8. //$sql .= " FROM " .$GLOBALS['ecs']->table('comment');
  9. //$sql .= "WHERE STATUS =1 AND comment_type =0) ";
  10. //$sql .= " UNION ";
  11. $sql .= "SELECT 'feedback' AS tablename, msg_id AS ID, msg_content AS msg_content, msg_title AS msg_title, msg_time AS msg_time, null AS id_value, null AS comment_rank, message_img AS message_img, user_name AS user_name, msg_type AS msg_type ";
  12. $sql .= " FROM " .$GLOBALS['ecs']->table('feedback');
  13. $sql .= " WHERE `msg_area`='1' AND `msg_status` = '1' ";
  14. $sql .= " ORDER BY msg_time DESC ";
  15. }
复制代码

message.php经如上修改后是否与index.php的产生冲突呢?

  1. function get_msg_list($num, $start)
  2. {
  3. /* 获取留言数据 */
  4. $msg = array();
  5. //$sql = "SELECT * FROM " .$GLOBALS['ecs']->table('feedback');
  6. //$sql .= " WHERE `msg_area`='1' ORDER BY msg_time DESC";

  7. $sql = "SELECT * FROM " .$GLOBALS['ecs']->table('feedback') . "WHERE `msg_area`='1' ORDER BY msg_time DESC";

  8. //$res = $GLOBALS['db']->SelectLimit($sql, $num, $start);
  9. $res = $GLOBALS['db']->SelectLimit($sql, ($num-6) , $start);
  10. while ($rows = $GLOBALS['db']->fetchRow($res))
  11. {
  12. $reply = array();
  13. $sql = "SELECT user_name, user_email, msg_time, msg_content".
  14. " FROM " .$GLOBALS['ecs']->table('feedback') .
  15. " WHERE parent_id = '" . $rows['msg_id'] . "'";
  16. $reply = $GLOBALS['db']->getRow($sql);
  17. if ($reply)
  18. {
  19. $msg[$rows['msg_id']]['re_user_name'] = $reply['user_name'];
  20. $msg[$rows['msg_id']]['re_user_email'] = $reply['user_email'];
  21. $msg[$rows['msg_id']]['re_msg_time'] = local_date($GLOBALS['_CFG']['time_format'], $reply['msg_time']);
  22. $msg[$rows['msg_id']]['re_msg_content'] = nl2br(htmlspecialchars($reply['msg_content']));
  23. }
  24. $msg[$rows['msg_id']]['user_name'] = htmlspecialchars($rows['user_name']);
  25. $msg[$rows['msg_id']]['msg_content'] = nl2br(htmlspecialchars($rows['msg_content']));
  26. $msg[$rows['msg_id']]['msg_time'] = local_date($GLOBALS['_CFG']['time_format'], $rows['msg_time']);
  27. $msg[$rows['msg_id']]['msg_type'] = $GLOBALS['_LANG']['message_type'][$rows['msg_type']];
  28. $msg[$rows['msg_id']]['msg_title'] = nl2br(htmlspecialchars($rows['msg_title']));
  29. $msg[$rows['msg_id']]['message_img'] = $rows['message_img'];
  30. $msg[$rows['msg_id']]['order_id'] = $rows['order_id'];
  31. }
  32. return $msg;
  33. }
复制代码