dtdd25012 2014-04-06 05:08
浏览 42
已采纳

在codeigniter中错误非法字符串偏移

i am getting error illegal sting offset in variable 'slug' and 'judul' in my view. can you tell me what the probelm.

controller

function index()
{
    $slug = $this->uri->segment(2);
    $this->data['halaman'] = $this->mhalaman->get_profil($slug);

    if (empty($this->data['halaman'])) {
        show_404();
    }
    $this->data['judul'] = $this->data['halaman']['judul'];
    //var_dump($halaman_item['slug']);
    $this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
    $this->data['contents'] = $this->load->view('page', $this->data, true);
    $this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}

view

<div class="section ui dropdown link item">
                        <span class="count">Profil</span>
                        <div class="menu">

                            <?php foreach ($halaman as $dt) : ?>
                            <div class="item">
                              <a href="/tkd/index.php/page/<?php echo $dt['slug'] ?>"><?php echo $dt['judul'] ?></a> //line error
                            </div>

                        <?php endforeach; ?>
                        </div>
                      </div>

modal

function get_profil($slug = FALSE)
    {
        if ($slug === FALSE)
        {
            $query = $this->db->get($this->tbl_halaman);
            return $query->result_array();
        }

        $query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
        return $query->row_array();
    }

please help me what to do. thank you

  • 写回答

1条回答 默认 最新

  • dongshuo6503 2014-04-06 05:16
    关注

    It should be echo $dt instead of echo $dt['slug']

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ensp,用局域网解决
  • ¥15 Python语言实验
  • ¥15 我每周要在投影仪优酷上自动连续播放112场电影,我每一周遥控操作一次投影仪,并使得电影永远不重复播放,请问怎样操作好呢?有那么多电影看吗?
  • ¥20 电脑重启停留在grub界面,引导出错需修复
  • ¥15 matlab透明图叠加
  • ¥50 基于stm32l4系列 使用blunrg-ms的ble gatt 创建 hid 服务失败
  • ¥150 计算DC/DC变换器平均模型中的参数mu
  • ¥25 C语言代码,大家帮帮我
  • ¥15 请问以下文字内容及对应编码是用了什么加密算法或压缩算法呢?
  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)