我正在使用此基于CodeIgniter的头像社区引擎,除商店系统外,其他所有东西都在工作。

每当我尝试购买商品时,我都会得到:


  遇到错误
  
  shop_item_id必须有效


我将问题缩小为这段代码:

public function purchase_item()
{
    $shop_item_id = $this->input->post('item_id');

    if(!is_numeric($shop_item_id)) show_error('shop_item_id must be valid');

    $shop_item_query = $this->db->join('avatar_items', 'avatar_items.item_id = shop_items.item_id')->get_where('shop_items', array('shop_item_id' => $shop_item_id));

    if($shop_item_query->num_rows() > 0):
        $shop_item_data = $shop_item_query->row_array();
    else:
        show_error('shop_item could not be found.');
    endif;

    $shop_id = $shop_item_data['shop_id'];

    if ( ! $shop_data = $this->cache->get('shop_data_'.$shop_id)):
        $shop_data = $this->db->get_where('shops', array('shop_id' => $shop_id))->row_array();
        $this->cache->save('shop_data_'.$shop_id, $shop_data, 2400);
    endif;


解决办法是什么?

ps:我使用的是crysandrea(https://github.com/tylerdiaz/Crysandrea)脚本。我需要这份工作。

这是代码:

        <form action="/shops/purchase_item/" method="POST">
        <input type="hidden" name="item_id" value="<?php echo $item_data['shop_item_id'] ?>" />
        <button type="submit" class="main_button">Purchase item</button>
    </form>

最佳答案

你忘了分号。现在尝试以下代码

  <form action="/shops/purchase_item/" method="POST">
        <input type="hidden" name="item_id" value="<?php echo $item_data['shop_item_id']; ?>" />
        <button type="submit" class="main_button">Purchase item</button>
    </form>

10-07 21:20