codeigniter,试图让非对象的属性 [英] Codeigniter, Trying to get property of non-object

查看:177
本文介绍了codeigniter,试图让非对象的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CI形象托管网站与图像视图文件(运行良好)和图像的专辑之一,然而相册视图是生产以下错误试图让非对象的特性。我试图寻找,但不能看到我做错了什么。

I have a image hosting site in CI with an image view file (working well) and an image album one, however the album view is producing the following error 'Trying to get property of non-object'. I've tried searching but cant see what I'm doing wrong.

有这个问题,我认为该地区是(这条线:如果($行级别> ID == $ id_array [$关键]):')

The area in my view which has this issue is (this line 'if($row->id == $id_array[$key]):'):

<?php if(count($records_array) != 1) : ?>
<div class="album-images">

<?php $i = 0; $links_array = array(); ?>
    <?php foreach ($records_array as $key => $records) {
    if(isset($records)) : foreach($records as $row) : ?>

        <?php if($row->id == $id_array[$key]):   ?>
        <?php $i++; ?>
        <?php

        //get array of ids for linking
        foreach ($id_array as $key => $ids) {
            array_push($links_array, alphaID($id_array[$key]));
        }

我的另一种观点具有完全相同的code这就是为什么它是那么的陌生。

My other view has the exact same code which is why it's so strange.

下面是records_array内容】: http://pastebin.com/6pyTCBSH

Here's the content of records_array[] : http://pastebin.com/6pyTCBSH

而id_array [](包含图片专辑的ID)

And the id_array[] (contains the album images id's)

Array
(

    [0] => 2738
    [1] => 2758
)

的records_array在该文件的顶部使用的自己相关 http://pastebin.com/yF2yXrxK

有人能看到为什么会这样?关于25-30times了网页错误输出。

Can anyone see why this is happening? The error outputs about 25-30times down the page.

推荐答案

该错误试图让非对象的属性的意思是你要访问一些变量或方法这不是一个对象。在这种情况下,你要访问变量 ID $行,但 $行不是一个对象。

The error "Trying to get property of non-object" mean that you're trying to access a variable or method on something that isn't an object. In this case, you're trying to access the variable id from $row, but $row isn't an object.

根据其中数据来源于,也许它是一个数组,在这种情况下,你应该访问 ID 属性为 $行['身份证']

Depending on where the data comes from, perhaps it's an array, in which case you should access the id property as $row['id'].

在此情况下失败,那么我建议你做的print_r($行)来弄清楚究竟是什么 $行包含

In case this fails as well, I'd suggest you do print_r($row) to figure out what exactly $row contains.

这篇关于codeigniter,试图让非对象的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆