【求助】新增了个字段,但是没法输入数据

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

给产品增加了一个字段,goods_url,按照这个帖子(http://bbs.ecshop.com/thread-119955-1-1.html)的说明,添加字段成功,前台也能正常调用,但是就是在后台没法输入数据,总是显示默认数据,如附件所示。直接操作数据,能够正常输入url,前台正常调用,后台也能正常读入,但是一修改就又变成附件那样了。搞了一晚上也没搞定。下面是我的admin/goods.php的相关代码,求高手帮忙。

  1. /* 处理商品数据 */
  2. $shop_price = !empty($_POST['shop_price']) ? $_POST['shop_price'] : 0;
  3. $goods_url = !empty($_POST['goods_url']) ? $_POST['goods_url'] : 0;
  4. $market_price = !empty($_POST['market_price']) ? $_POST['market_price'] : 0;
  5. $promote_price = !empty($_POST['promote_price']) ? floatval($_POST['promote_price'] ) : 0;
  6. $is_promote = empty($promote_price) ? 0 : 1;
  7. $promote_start_date = ($is_promote && !empty($_POST['promote_start_date'])) ? local_strtotime($_POST['promote_start_date']) : 0;
  8. $promote_end_date = ($is_promote && !empty($_POST['promote_end_date'])) ? local_strtotime($_POST['promote_end_date']) : 0;
  9. $goods_weight = !empty($_POST['goods_weight']) ? $_POST['goods_weight'] * $_POST['weight_unit'] : 0;
  10. $is_best = isset($_POST['is_best']) ? 1 : 0;
  11. $is_new = isset($_POST['is_new']) ? 1 : 0;
  12. $is_hot = isset($_POST['is_hot']) ? 1 : 0;
  13. $is_on_sale = isset($_POST['is_on_sale']) ? 1 : 0;
  14. $is_alone_sale = isset($_POST['is_alone_sale']) ? 1 : 0;
  15. $goods_number = isset($_POST['goods_number']) ? $_POST['goods_number'] : 0;
  16. $warn_number = isset($_POST['warn_number']) ? $_POST['warn_number'] : 0;
  17. $goods_type = isset($_POST['goods_type']) ? $_POST['goods_type'] : 0;
  18. $give_integral = isset($_POST['give_integral']) ? intval($_POST['give_integral']) : '-1';
  19. $rank_integral = isset($_POST['rank_integral']) ? intval($_POST['rank_integral']) : '-1';

  20. $goods_name_style = $_POST['goods_name_color'] . '+' . $_POST['goods_name_style'];

  21. $catgory_id = empty($_POST['cat_id']) ? '' : intval($_POST['cat_id']);
  22. $brand_id = empty($_POST['brand_id']) ? '' : intval($_POST['brand_id']);

  23. $goods_img = (empty($goods_img) && !empty($_POST['goods_img_url']) && goods_parse_url($_POST['goods_img_url'])) ? htmlspecialchars(trim($_POST['goods_img_url'])) : $goods_img;
  24. $goods_thumb = (empty($goods_thumb) && !empty($_POST['goods_thumb_url']) && goods_parse_url($_POST['goods_thumb_url'])) ? htmlspecialchars(trim($_POST['goods_thumb_url'])) : $goods_thumb;
  25. $goods_thumb = (empty($goods_thumb) && isset($_POST['auto_thumb']))? $goods_img : $goods_thumb;

  26. /* 入库 */
  27. if ($is_insert)
  28. {
  29. if ($code == '')
  30. {
  31. $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
  32. "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
  33. "goods_url, " .
  34. "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
  35. "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
  36. "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" .
  37. "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
  38. "'$brand_id', '$shop_price', '$goods_url', '$market_price', '$is_promote','$promote_price', ".
  39. "'$goods_url', ".
  40. "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
  41. "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
  42. " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
  43. " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
  44. }
  45. else
  46. {
  47. $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
  48. "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
  49. "goods_url, " .
  50. "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
  51. "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
  52. "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" .
  53. "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
  54. "'$brand_id', '$shop_price', '$goods_url', '$market_price', '$is_promote','$promote_price', ".
  55. "'$goods_url', ".
  56. "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
  57. "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
  58. " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', ".
  59. " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";
  60. }
  61. }
  62. else
  63. {
  64. /* 如果有上传图片,删除原来的商品图 */
  65. $sql = "SELECT goods_thumb, goods_img, original_img " .
  66. " FROM " . $ecs->table('goods') .
  67. " WHERE goods_id = '$_REQUEST[goods_id]'";
  68. $row = $db->getRow($sql);
  69. if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
  70. {
  71. @unlink(ROOT_PATH . $row['goods_img']);
  72. @unlink(ROOT_PATH . $row['original_img']);
  73. }

  74. if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
  75. {
  76. @unlink(ROOT_PATH . $row['goods_thumb']);
  77. }

  78. $sql = "UPDATE " . $ecs->table('goods') . " SET " .
  79. "goods_name = '$_POST[goods_name]', " .
  80. "goods_name_style = '$goods_name_style', " .
  81. "goods_sn = '$goods_sn', " .
  82. "cat_id = '$catgory_id', " .
  83. "brand_id = '$brand_id', " .
  84. "shop_price = '$shop_price', " .
  85. "goods_url = '$goods_url', " .
  86. "market_price = '$market_price', " .
  87. "is_promote = '$is_promote', " .
  88. "promote_price = '$promote_price', " .
  89. "promote_start_date = '$promote_start_date', " .
  90. "promote_end_date = '$promote_end_date', ";

  91. /* 如果有上传图片,需要更新数据库 */
  92. if ($goods_img)
  93. {
  94. $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";
  95. }
  96. if ($goods_thumb)
  97. {
  98. $sql .= "goods_thumb = '$goods_thumb', ";
  99. }
  100. if ($code != '')
  101. {
  102. $sql .= "is_real=0, extension_code='$code', ";
  103. }
  104. $sql .= "keywords = '$_POST[keywords]', " .
  105. "goods_brief = '$_POST[goods_brief]', " .
  106. "seller_note = '$_POST[seller_note]', " .
  107. "goods_weight = '$goods_weight'," .
  108. "goods_url = '$goods_url'," .
  109. "goods_number = '$goods_number', " .
  110. "warn_number = '$warn_number', " .
  111. "integral = '$_POST[integral]', " .
  112. "give_integral = '$give_integral', " .
  113. "rank_integral = '$rank_integral', " .
  114. "is_best = '$is_best', " .
  115. "is_new = '$is_new', " .
  116. "is_hot = '$is_hot', " .
  117. "is_on_sale = '$is_on_sale', " .
  118. "is_alone_sale = '$is_alone_sale', " .
  119. "goods_desc = '$_POST[goods_desc]', " .
  120. "last_update = '". gmtime() ."', ".
  121. "goods_type = '$goods_type' " .
  122. "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
  123. }
  124. $db->query($sql);
复制代码

ec1.jpg (15.92 KB)

ec1.jpg


回答:
不是看这里。你获取的时候。是不是intval处理了

不是看这里。你获取的时候。是不是intval处理了
netaxcess 发表于 2010-10-29 09:34


能告诉我看哪里吗,我技术基本不懂,都是跟着别人依葫芦画瓢