首页调用评论为何是错误语句

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

如下图

回答:
请大侠帮我看下。库文件代码:
  1. <?php

  2. if(!function_exists("get_comments")){
  3. function get_comments($num)
  4. {
  5. $sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') .
  6. ' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id = 0 and a.comment_type=0 and a.id_value=b.goods_id '.
  7. ' ORDER BY a.add_time DESC';
  8. if ($num > 0)
  9. {
  10. $sql .= ' LIMIT ' . $num;
  11. }
  12. //echo $sql;

  13. $res = $GLOBALS['db']->getAll($sql);
  14. $comments = array();
  15. foreach ($res AS $idx => $row)
  16. {

  17. $comments[$idx]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
  18. $comments[$idx]['content'] = $row['content'];
  19. $comments[$idx]['id_value'] = $row['id_value'];
  20. $comments[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
  21. $comments[$idx]['goods_name'] = $row['goods_name'];
  22. }
  23. return $comments;
  24. }
  25. }

  26. ?>


  27. <!--数据调用-最新评论开始 -->
  28. <?php
  29. $this->assign('my_comments',get_comments(5)); // 数据条数
  30. ?>

  31. <div class="mod2con" style="padding:10px;">

  32. <!--{foreach from=$my_comments item=comments}-->
  33. <a href="goods.php?id={$comments.id_value}" target="_blank" style="float:left; width:230px; overflow:hidden; height:22px; line-height:22px; ">{$comments.content|truncate:30:""}</a>
  34. <font style="margin-left:20px; color:#CCC; float:right;">{$comments.add_time}</font><br>

  35. <!--{/foreach}-->

  36. </div>
复制代码



我猜,你肯定是装了官方最新的补丁包。
你的模板文件里有PHP代码,装了官方最新补丁包, 就会这样的

你别覆盖下面这个文件就没事了
includes/cls_template.php