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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:31:45+00:00 2026-06-14T18:31:45+00:00

I currently am building a small and simple referral system. However I am having

  • 0

I currently am building a small and simple referral system. However I am having trouble trying to return how many referrals one single user has. When a new user registers it stores in a column called “referid” and that ID in there correspond to the ID of the username who referred him.

However, upon attempting to find how many times that user’s ID is mentioned in the “referid” column and then echoing it, I get this error:

Catchable fatal error: Object of class PDOStatement could not be converted to string in /home/refined/public_html/refer.php on line 30

I cant understand what’s actually causing this. I did a quick google and all I could see was that PDO isn’t compatible with strings or something. I haven’t used PHP and MYSQL together that much before so I’m not sure how to “not” use PDO.

<?php
$checknumber = $odb -> prepare("SELECT COUNT('referid') FROM `users` WHERE `ID` = :ID");
$checknumber -> execute(array(':ID' => $_SESSION['ID']));
echo($checknumber);
?>

Any help is very much appreciated.

  • 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-14T18:31:46+00:00Added an answer on June 14, 2026 at 6:31 pm

    Let’s analyse your code:

    $checknumber = $odb -> prepare("SELECT COUNT('referid') FROM `users` WHERE `ID` = :ID");
    

    … where PDO::prepare() is defined as:

    PDOStatement PDO::prepare ( string $statement [, array $driver_options
    = array() ] )

    So it returns an object. But two lines later you try to print the object:

    echo($checknumber);
    

    If you check any of the usage examples in the manual you’ll see that you need to call one of the PDOStatement methods to extract the query results, e.g.:

    <?php
    /* Execute a prepared statement by passing an array of values */
    $sql = 'SELECT name, colour, calories
        FROM fruit
        WHERE calories < :calories AND colour = :colour';
    $sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $sth->execute(array(':calories' => 150, ':colour' => 'red'));
    $red = $sth->fetchAll();
    

    Update: Two more links:

    • Available PDOStatement methods
    • Arrays in PHP
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently building a very small/simple web application in ASP.NET MVC with ADO.NET
I'm currently building a portfolio site for a client, and I'm having trouble with
I am building a very small shopping cart system with php/mysql. Currently the actual
Hi I am building a small simple JS framework for University. I am having
I'm currently building an app for managing a small organization. One of the functions
I am currently building a small visual designer using the Netbeans Platform. All my
I'm currently building a semi-small ruby app for a project. The problem I'm currently
We're currently building multiple copies of our Chrome CRX, one for each of our
Some background I'm currently building a predominantly classic web app (rather than a single
I am currently building a small web application for publishing stories using PHP and

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.