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 9004211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:51:08+00:00 2026-06-16T00:51:08+00:00

I am receiving the following error below on the object’s function in Smarty and

  • 0

I am receiving the following error below on the object’s function in Smarty and I am unaware of how to resolve the issue.

Error:

Catchable fatal error: Object of class users_class could not be converted to string

This is the following object and function of the object I am using.

class users_class
{
    public function fetchUser(array $conditions)
    {
        $db = Core::getInstance();
        $sql = "SELECT * FROM ".USERS." WHERE ";
        $i=0;
        $params = array();
        //$where = array();
        foreach ($conditions as $column => $value)
        {
            if (preg_match('/^[a-z-.-_]+$/', $column)) {
                if ($i!=0) {
                    $sql .= " AND ";
                }
                $sql .= "$column = ?";
                $params[] = $value;
                $i++;
            }
        }           
        //$sql .= implode(' AND ', $where);
        //$sql .= " order by title asc";    
        $res = $db->dbh->prepare($sql);
        $res->execute(array_values($params));
        return $res->fetch(PDO::FETCH_ASSOC);               
    }
}

This is the call in Smarty:

 {section name=ststval loop=$ststres}
    {if $ststres[ststval].type == 2}
       {assign var='udatas' value="$userObj->fetchUser(array('id'=>$ststres[ststval].to_id));"}
  • 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-16T00:51:09+00:00Added an answer on June 16, 2026 at 12:51 am

    I solved this by adding the __toString() method to the object. Apparently, the object just has to return a string. This was confusing to me because I didn’t know what it should return and directions were not clear on php.net. For a person learning PHP things need to be explained when asked for help not pointed to the same articles everyone reads when learning PHP. I believe we come asking for help on websites like these because we require explanations from people with higher knowledge. I call it lazy and unhelpful!

    class users_class
    {
    
        protected $users_class='';
    
        public function __toString() {
       
            return (string)$this->users_class;
        }
    
    
        public function fetchUser(array $conditions)
        {
            $db = Core::getInstance();
            $sql = "SELECT * FROM ".USERS." WHERE ";
            $i=0;
            $params = array();
            //$where = array();
            foreach ($conditions as $column => $value)
            {
                if (preg_match('/^[a-z-.-_]+$/', $column)) {
                    if ($i!=0) {
                        $sql .= " AND ";
                    }
                    $sql .= "$column = ?";
                    $params[] = $value;
                    $i++;
                }
            }           
            //$sql .= implode(' AND ', $where);
            //$sql .= " order by title asc";    
            $res = $db->dbh->prepare($sql);
            $res->execute(array_values($params));
            return $res->fetch(PDO::FETCH_ASSOC);               
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am receiving an error on the following line of code: Object reference not
I am receiving the following error when running my below ruby script: s3parse.rb:12:in `block
I am receiving the following error from the code below. You have an error
I'm receiving the following error from the query below: Syntax error (missing operator) in
I am receiving the following error when running my code below /Users/Castillo/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:1423:in stat': No
I'm receiving the following error when I run collectstatic: AttributeError: 'cStringIO.StringO' object has no
I am receiving the following error from the below query, as I am trying
I'm receiving the following error on log file. (java.lang.SecurityException: class "com.adventnet.snmp.snmp2.SecurityModelTable"'s signer information does
I've been receiving errors with the following code below saying that the index is
Background I'm receiving the following error when trying to render a partial view in

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.