Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:40:34+00:00 2026-06-09T13:40:34+00:00

$this->db->from(‘posts’); $this->db->where(‘id’,$this->uri->segment(3)); $data[‘query’] = $this->db->get(); I am trying to get one post using a

  • 0
$this->db->from('posts');
$this->db->where('id',$this->uri->segment(3));
$data['query'] = $this->db->get();

I am trying to get one post using a where statement. I don’t get any errors when I run this code. But in my view when I try to get $query->result()->body PHP gives me an error Trying to get property of non-object. So I ran print_r($query) and this is what it gave me:

(
    [conn_id] => Resource id #27
    [result_id] => Resource id #32
    [result_array] => Array
        (
        )

    [result_object] => Array
        (
        )

    [custom_result_object] => Array
        (
        )

    [current_row] => 0
    [num_rows] => 0
    [row_data] => 
)

I have no idea why it won’t get my specific post from the database. I know my database is in working condition. I use it elsewhere in my site. I also use $this->db->where() elsewhere on my site and it works perfect. I’ve also tried plugging in id’s of posts instead of $this->uri->segment(3) and I get the same problem. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:40:36+00:00Added an answer on June 9, 2026 at 1:40 pm

    result() should be used when you are selecting more than 1 row from db, use row() instead.

    In controller use

    $data['query'] = $this->db->get()->row();
    

    And then in view

    $query->body
    

    I strongly reccomend you to use $data['post'] and $post->body instead of $query->body. When you will have more queries on one page, your view will get messy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this from print_r($data) : Array ( [0] => Array ( [0] =>
I query-ing this from entity framework using WCF, and i want to use the
I got this from one test and really didn't get the point. Which one
I've been struggling with this from yesterday. I'm trying to do an if statement
I've been trying this from a long time. I'm having today's date and I
If I execute this from SQL Server, I get the output parameter with no
Call this from a QWidget: Parser->xmlParser(_layout, xmlPath, comingFrom, mapCount); , but get two No
get this from my database: 252.587254564 Well i wanna remove the .587254564 and keep
I got this from a berkley cs data structures webcast: class A { void
I'm using this from the command line: perl -MDateTime::Format::DateManip -le 'print $Some::Module::VERSION' but only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.