wap版 评论只有首页正常 后页全部显示Undefined variable: comment_data

2016-07-07 15:11 来源:www.chinab4c.com 作者:ecshop专家

Undefined variable: comment_data in D:\web\eachfa.com\mobile\comment.php on line 68


http://www.pctowap.com/air/eachf ... ?g_id=75&page=1

回答:

貌似只能查代码了,模板跳转看上去正常...

貌似只能查代码了,模板跳转看上去正常...
lilong1980 发表于 2012-11-17 23:02


冰天雪地求高手百忙之中 帮忙看一下:

  1. <?php
  2. /**
  3. * ECSHOP WAP评论页
  4. * ============================================================================
  5. * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.ecshop.com;
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * $Author: testyang $
  12. * $Id: comment.php 15013 2008-10-23 09:31:42Z testyang $
  13. */
  14. define('IN_ECS', true);
  15. require(dirname(__FILE__) . '/includes/init.php');
  16. $goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit();
  17. if ($goods_id <= 0)
  18. {
  19. exit();
  20. }
  21. /* 读取商品信息 */
  22. $_LANG['kilogram'] = '千克';
  23. $_LANG['gram'] = '克';
  24. $_LANG['home'] = '首页';
  25. $smarty->assign('goods_id', $goods_id);
  26. $goods_info = get_goods_info($goods_id);
  27. $goods_info['goods_name'] = encode_output($goods_info['goods_name']);
  28. $goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
  29. $smarty->assign('goods_info', $goods_info);
  30. /* 读评论信息 */
  31. $comment = assign_comment($goods_id, 'comments');
  32. $num = $comment['pager']['record_count'];
  33. if ($num > 0)
  34. {
  35. $page_num = '10';
  36. $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
  37. $pages = ceil($num / $page_num);
  38. if ($page <= 0)
  39. {
  40. $page = 1;
  41. }
  42. if ($pages == 0)
  43. {
  44. $pages = 1;
  45. }
  46. if ($page > $pages)
  47. {
  48. $page = $pages;
  49. }
  50. $i = 1;
  51. foreach ($comment['comments'] as $key => $data)
  52. {
  53. if (($i > ($page_num * ($page - 1 ))) && ($i <= ($page_num * $page)))
  54. {
  55. $re_content = !empty($data['re_content']) ? encode_output($data['re_content']) : '';
  56. $re_username = !empty($data['re_username']) ? encode_output($data['re_username']) : '';
  57. $re_add_time = !empty($data['re_add_time']) ? substr($data['re_add_time'], 5, 14) : '';
  58. $comment_data[] = array('i' => $i , 'content' => encode_output($data['content']) , 'username' => encode_output($data['username']) , 'add_time' => substr($data['add_time'], 5, 14) , 're_content' => $re_content , 're_username' => $re_username , 're_add_time' => $re_add_time);
  59. }
  60. $i++;
  61. }
  62. $smarty->assign('comment_data', $comment_data);
  63. $pagebar = get_wap_pager($num, $page_num, $page, 'comment.php?g_id='.$goods_id, 'page');
  64. $smarty->assign('pagebar' , $pagebar);
  65. }
  66. $smarty->assign('footer', get_footer());
  67. $smarty->display('comment.html');
  68. ?>
复制代码

ding.......

在循环前面声明一个 $comment_data = array()



谢谢大神!加了后第二页仍然不显示评论
  1. <?php

  2. /**
  3. * ECSHOP WAP评论页
  4. * ============================================================================
  5. * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.ecshop.com;
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * $Author: testyang $
  12. * $Id: comment.php 15013 2008-10-23 09:31:42Z testyang $
  13. */

  14. define('IN_ECS', true);

  15. require(dirname(__FILE__) . '/includes/init.php');

  16. $goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit();
  17. if ($goods_id <= 0)
  18. {
  19. exit();
  20. }
  21. /* 读取商品信息 */
  22. $_LANG['kilogram'] = '千克';
  23. $_LANG['gram'] = '克';
  24. $_LANG['home'] = '首页';
  25. $smarty->assign('goods_id', $goods_id);
  26. $goods_info = get_goods_info($goods_id);
  27. $goods_info['goods_name'] = encode_output($goods_info['goods_name']);
  28. $goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
  29. $smarty->assign('goods_info', $goods_info);

  30. /* 读评论信息 */
  31. $comment = assign_comment($goods_id, 'comments');

  32. $num = $comment['pager']['record_count'];
  33. if ($num > 0)
  34. {
  35. $page_num = '10';
  36. $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
  37. $pages = ceil($num / $page_num);
  38. if ($page <= 0)
  39. {
  40. $page = 1;
  41. }
  42. if ($pages == 0)
  43. {
  44. $pages = 1;
  45. }
  46. if ($page > $pages)
  47. {
  48. $page = $pages;
  49. }
  50. $i = 1;
  51. $comment_data = array();
  52. foreach ($comment['comments'] as $key => $data)
  53. {
  54. if (($i > ($page_num * ($page - 1 ))) && ($i <= ($page_num * $page)))
  55. {
  56. $re_content = !empty($data['re_content']) ? encode_output($data['re_content']) : '';
  57. $re_username = !empty($data['re_username']) ? encode_output($data['re_username']) : '';
  58. $re_add_time = !empty($data['re_add_time']) ? substr($data['re_add_time'], 5, 14) : '';
  59. $comment_data[] = array('i' => $i , 'content' => encode_output($data['content']) , 'username' => encode_output($data['username']) , 'add_time' => substr($data['add_time'], 5, 14) , 're_content' => $re_content , 're_username' => $re_username , 're_add_time' => $re_add_time);
  60. }
  61. $i++;
  62. }
  63. $smarty->assign('comment_data', $comment_data);
  64. $pagebar = get_wap_pager($num, $page_num, $page, 'comment.php?g_id='.$goods_id, 'page');
  65. $smarty->assign('pagebar' , $pagebar);
  66. }

  67. $smarty->assign('footer', get_footer());
  68. $smarty->display('comment.html');

  69. ?>
复制代码

这是什么?

ding。。。。!

WAP版模版不完整。ECSHOP学习资料:http://www.phpally.com




看了你的站 没有关于这个问题的相关资料

ding。。。。!

按下代码修改就可以了
V2.7.3测试: http://www.sepor.cn/mobile/comment.php?g_id=1156
  1. <?php

  2. /**
  3. * ECSHOP WAP评论页
  4. * ============================================================================
  5. * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.ecshop.com;
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * $Author: testyang $
  12. * $Id: comment.php 15013 2008-10-23 09:31:42Z testyang $
  13. */

  14. define('IN_ECS', true);

  15. require(dirname(__FILE__) . '/includes/init.php');

  16. $goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit();
  17. if ($goods_id <= 0)
  18. {
  19. exit();
  20. }
  21. /* 读取商品信息 */
  22. $_LANG['kilogram'] = '千克';
  23. $_LANG['gram'] = '克';
  24. $_LANG['home'] = '首页';
  25. $smarty->assign('goods_id', $goods_id);
  26. $goods_info = get_goods_info($goods_id);
  27. $goods_info['goods_name'] = encode_output($goods_info['goods_name']);
  28. $goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
  29. $smarty->assign('goods_info', $goods_info);
  30. $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;

  31. /* 读评论信息 */
  32. $comment = assign_comment($goods_id, 'comments',$page);

  33. $num = $comment['pager']['record_count'];
  34. if ($num > 0)
  35. {
  36. $page_num = !empty($GLOBALS['_CFG']['comments_number']) ? $GLOBALS['_CFG']['comments_number'] : 5;

  37. $pages = ceil($num / $page_num);
  38. if ($page <= 0)
  39. {
  40. $page = 1;
  41. }
  42. if ($pages == 0)
  43. {
  44. $pages = 1;
  45. }
  46. if ($page > $pages)
  47. {
  48. $page = $pages;
  49. }
  50. $i = 1 + ($page-1)*$page_num;
  51. foreach ($comment['comments'] as $key => $data)
  52. {
  53. if (($i > ($page_num * ($page - 1 ))) && ($i <= ($page_num * $page)))
  54. {
  55. $re_content = !empty($data['re_content']) ? encode_output($data['re_content']) : '';
  56. $re_username = !empty($data['re_username']) ? encode_output($data['re_username']) : '';
  57. $re_add_time = !empty($data['re_add_time']) ? substr($data['re_add_time'], 5, 14) : '';
  58. $comment_data[] = array('i' => $i , 'content' => encode_output($data['content']) , 'username' => encode_output($data['username']) , 'add_time' => substr($data['add_time'], 5, 14) , 're_content' => $re_content , 're_username' => $re_username , 're_add_time' => $re_add_time);
  59. }
  60. $i++;
  61. }
  62. $smarty->assign('comment_data', $comment_data);
  63. $pagebar = get_wap_pager($num, $page_num, $page, 'comment.php?g_id='.$goods_id, 'page');
  64. $smarty->assign('pagebar' , $pagebar);
  65. }

  66. $smarty->assign('footer', get_footer());
  67. $smarty->display('comment.html');

  68. ?>
复制代码