CodeIgniter: Undefined property: stdClass::$CategoryID

I'm inner joining two databases together here, when using the separate views individually they work fine, so do the databases, I think the cause of this is the inner join, but putting the query directly into phpmyadmin and replacing the $categoryID with a number works.

Some rows load, such as the images, but joined variables are undefined, What is causing the variables to be undefined?


function DisplayBySpecificCategory($categoryID) 
    $query = $this->db->query("SELECT * FROM CIUploads
                               INNER JOIN CIUsers ON CIUploads.UserID = CIUsers.UserID
                               WHERE CIUploads.UploadCategoryID = $categoryID 
                               ORDER BY CIUploads.UploadTime DESC");
    return $query->result();


function SpecificCategory()

        $data['category'] = $this->Category_model->GenerateCategoryHeader($categoryID);
        $data['allwork'] = $this->Previews_model->DisplayBySpecificCategory($categoryID);
        $this->load->view('headers/Specific_category_header', $data);
        $this->load->view('previews/Previews_view', $data); 

Header view:

<?php foreach ($category as $value2){ ?> 
    <header style="background-color:#<?php echo $value2->CategoryColor ?>">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="page-intro">
                        <h1 class="inverted text-center"><?php echo $value2->CategoryTitle ?></h1>
                        <p class="inverted text-center"><?php echo $value2->CategoryDescription ?></p>
<?php } ?>

Previews view:

                    if($value->UploadCategoryID == 2){
                        echo '<video muted class="video-responsive fit-centered">'; 
                            echo '<source src="'.base_url("/public/uploads/works")."/".$value->UploadedAt.'" type="video/mp4">Your browser does not support the video tag.'; 
                        echo '</video>'; 

                     else if($value->UploadCategoryID == 3){ 
                        echo '<iframe class="fit-centered" src="http://'.$value->UploadedAt.'" scrolling="no"></iframe>';

                        echo '<img class="img-responsive fit-centered" src="'.base_url("/public/uploads/works")."/".$value->UploadedAt.'" alt="'.$value->UploadTitle.'">';
                    } ?>

                <div class="overlay">
                        <a href="<?php echo site_url("/Work_controller/ViewWork/".$value->UploadID) ?>" class="inverted"><i class="fa fa-eye fa-3x ease-color"></i></a>

            <div class="hovereffect-information no-bounding">
                <span class="category-tab pull-right text-center inverted" style="background-color:#<?php echo $value->CategoryColor ?>"><i class="fa <?php echo $value->CategoryIcon ?>"></i></span>
                <p class="pull-left no-bounding text-uppercase preview-info"><?php echo $value->UploadTitle ?></p>
                <a href="<?php echo site_url("/Profile_controller/ViewProfile/".$value->UserID)?>"><img class="img-responsive small-profile-img pull-right hover-dim fit-centered" src="<?php echo base_url("/public/uploads/profile-images/")."/".$value->ProfileImg ?>" alt="<?php echo $value->Username ?>"/></a>
                <p class="pull-left no-bounding text-uppercase preview-info">
                    <a href="<?php echo site_url("/Category_controller/ViewCategory/".$value->CategoryID) ?>"></a> 
                    <span class="preview-span"> <i class="fa fa-eye"></i> <?php echo $value->UploadViews ?> </span> |
                    <span class="preview-span"> <i class="fa fa-heart"></i> <?php echo $value->UploadLikes ?> </span> |
                    <span class="preview-span"> <i class="fa fa-comments"></i> <?php echo $value->UploadComments ?> </span> 
    <?php } ?> 


Severity: Notice

Message: Undefined property: stdClass::$CategoryIcon

Filename: previews/Previews_view.php

Line Number: 31


File: /web/stud/u1263522/cmw/application/views/previews/Previews_view.php Line: 31 Function: _error_handler

File: /web/stud/u1263522/cmw/application/controllers/Views_controller.php Line: 64 Function: view

File: /web/stud/u1263522/cmw/index.php Line: 292 Function: require_once


In the question you have mentioned : Undefined property: stdClass::$CategoryID

whereas the error shows : Undefined property: stdClass::$CategoryIcon

If $CategoryIcon is undefined it means that you do not have a column called CategoryIcon in any of your tables.

Can you mention the details of the tables?

It is always a good practice to mention the column names in the query instead of *.

Need Your Help

Transaction in middle of SQL Server Full bckup

sql-server database database-backups

If the full backup is started at 11 and completed at 4. at 2.30 there are some transaction happened. Will it be reflected on this full back up file?

How do you get the currently focused window in Titanium Mobile?


I'm attaching a resume event to the app and I want to detect what window is currently focused