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

  • Home
  • SEARCH
  • 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 6204071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:01:40+00:00 2026-05-24T05:01:40+00:00

I have a variable called $result which should store all the results from my

  • 0

I have a variable called $result which should store all the results from my database query however when I run print ($result) it gives an error message:

A PHP Error was encountered

Severity: 4096

Message: Object of class CI_DB_mysql_result could not be converted to
string

Filename: models/control_panel_model.php

Line Number: 72

Here is my model code:

public function view_record($record_id)
        {
            $criteria = array 
            (
                'procedure_id' => $record_id
            );

            echo $this->db->count_all('procedure');
            return;
            $this->db->select('procedure.procedure_id, procedure.patient_id, procedure.department_id, procedure.name_id , procedure.dosage_id');
            $this->db->from ('procedure');

            $this->db->join('patient', 'patient.patient_id = procedure.patient_id', 'inner');
            $this->db->join('department', 'department.department_id = procedure.department_id', 'inner');
            $this->db->join('procedure_name', 'procedure_name.procedure_name_id = procedure.name_id', 'inner');
            $this->db->join('dosage', 'dosage.dosage_id = procedure.dosage_id', 'inner');

            $this->db->where('procedure_id', $record_id);
            $result = $this->db->get();


            print($result);


            return ;


        }

The reason I am using a print function is just to test if my query is working and it has values. How do I achieve this.

Thanks

EDIT!!!

Here is what I get in var_dump();

object(CI_DB_mysql_result)#22 (8) { 
  ["conn_id"]=> resource(30) of type (mysql link persistent)
  ["result_id"]=> resource(40) of type (mysql result)
  ["result_array"]=> array(0) { }
  ["result_object"]=> array(0) { }
  ["custom_result_object"]=> array(0) { }
  ["current_row"]=> int(0)
  ["num_rows"]=> int(0) 
  ["row_data"]=> NULL
}

I HAVE ADDED THE FOLLOWING CODE:

if ($result->num_rows >0) {
echo “Data”;
}
else {
echo “No Data”;
}

IT IS SAYING THERE IS “NO DATA” so my query must be crap and wrong , so I need to redesign query. THERE IS DATA IN MY DATABASE SO must be query

===========================================

Here is my schema
https://i.stack.imgur.com/zSHSQ.png

enter image description here

  • 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-05-24T05:01:42+00:00Added an answer on May 24, 2026 at 5:01 am

    The object in question (CI_DB_mysql_result) is missing the __toString implementation that’s why you get the error.

    However, this can mean that the object can not be usefully converted to string.

    Instead you should convert the objects data to string first on your own for the purpose of your print operation. I can not say from the code you’ve posted which use you’re looking for specifically, so there is not more I can add to this.

    Please see Generating Query Results and Active Record Class.

    Edit: For a quick and dirty string-printing, you can use print_r, however I do not know if this is actually helpful for your case:

    $result = $this->db->get();
    print_r($result);
    

    That’s comparable to the suggestion given to use var_dump. You should say which kind of information you would like to print actually and for this you should know the type of data the database returns. See the documentation of get()Active Record Class for some examples how to work with the return values.

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

Sidebar

Related Questions

I have a PHP-variable called $go_Adress which contains the adress I need to get
Say I have stored a query in a variable called $query. I want to
I have a MySQL database called People which contains the following schema <id,name,foodchoice1,foodchoice2> .
I have a simple form which accepts a Title and a Contents variable from
The scenario would be: you have a variable called person which contains a number
I have a php-file called kal_test.php which gives a value to the variable $vbl
Say you have a variable called hotelPropertyNumber . The contents will always be a
I have a hidden input variable called str. I am assigning abc value to
I have a huge dictionary of blank values in a variable called current like
I have a paragraph of text in a javascript variable called 'input_content' and that

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.