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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:00:01+00:00 2026-06-09T23:00:01+00:00

I am crossing over to PDO and want to, simply put, return a single

  • 0

I am crossing over to PDO and want to, simply put, return a single value from a table (and I feel really stupid for not getting it right). I am not getting any errors, but also no values, where there should be 🙂

 try {
        $sql = "SELECT `column_name` FROM `table` ORDER BY `id` DESC LIMIT 1";
        $query = $this->handler->query($sql);
        $result = $query->fetchColumn();
        print_r($result);
    } 
    catch(PDOException $e) {
        return false;
    }
    return true;
  • 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-09T23:00:03+00:00Added an answer on June 9, 2026 at 11:00 pm

    Print the error message:

    catch(PDOException $e) {
        print_r($e->getMessage());
        return false;
    }
    

    As shown this would work, if you have correctly connected to the database.
    Check that your object is successfully connecting to the database, and that you have the correct column name and table name.

    A snippet from one of my DB classes:

    /**********************************************************************
    *  Try to connect to mySQL database
    */
    public function connect($dbuser, $dbpassword, $dbhost ,$dbname)
    {
        try {
            $this->dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpassword);
            $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            return true;
        } catch (PDOException $e) {
            $this->setError($e->getMessage());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Visual C++ 2008. First time, I'm experimenting in crossing over from C# and
Edit: It's not a bug as Martin pointed out. I'm just crossing the daylight
I have a query which is crossing two tables select count(*) from ingenium.empevt, ingenium.evt
I am showing text in tablevew. Some text is crossing cell. I want to
I need an algorithm to convert a closed bezier curve (perhaps self-crossing) to a
I have no idea why, but for some reason the top navigation at http://www.wilwaldon.com/crossing/badnav.html
I am porting over some C++ assembly to VB that performs demodulation of various
The user can select any number of week days from a list. An algorithm
I am currently crossing the jungle of SQL Server scale-out technologies like replication, log-shipping,
So when I make plots sometimes I see the y crossing x at some

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.