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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:22:59+00:00 2026-06-13T18:22:59+00:00

I am experiencing an issue with the values being returned from my PDO statement.

  • 0

I am experiencing an issue with the values being returned from my PDO statement.

This is my code:

//Execute test
$this->checkConnect();
$stmt = $this->dbh->prepare("SELECT p_id FROM People WHERE lastName = :param1 AND firstName = :param2");
$stmt->bindParam(':param1', $this->lName);
$stmt->bindParam(':param2', $this->fName);
$stmt->execute();
$count = $stmt->rowCount();

//Determine value of test
if($count == FALSE)
{
    return FALSE;
}
else
{
    $dummyvar = $stmt->fetch();
    $this->p_id = implode($dummyvar);
}

When I was going through my database records, I noticed that a certain value was off from what I had input. When I execute a query, it is supposed to grab the value of p_id from the tablePeople. Simple enough. However, what happens is that the number is appended twice to itself. For instance, say p_id is equal to 1. this->p_id will be equal to 11. Or is p_id is equal to 2, the output will be 22. I’ve executed this query within MySQL and the value is correct. I’m not sure what is happening in my php code. Perhaps something to do with implode? I’m not sure.

Any insight will be appreciated.

Addition: I should also state that p_id is unique, thus only one value can be returned.

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

    First, your fetch statement isn’t returning what you think it is. The default output array will have both column name keys, and numeric keys, something like this:

    array(
        0 => 1,
        'pid' => 1,
    )
    

    You probably want to get just a numerically-indexed array. Use PDO::FETCH_NUM like this:

    $dummyvar = $stmt->fetch(PDO::FETCH_NUM);
    

    Second, if you are going to output more than one field (not in this case obviously) then you have to fix your implode statement. You have to tell it what character to put between the different array values.

    $this->p_id = implode(' ', $dummyvar);
    

    For example:

    echo implode( ', ', array('a', 'b', 'c') );
    > 'a, b, c'
    

    References:

    • PDOStatement::fetch
    • implode
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some reasons i am experiencing this issue on my website. When the website loads
from today I've been experiencing an issue with Google Maps resulting into not centering
I'm experiencing a weird issue here. I have a Javascript code which scrolls my
I am experiencing an issue with v1 of Ninject and resetting the StandardKernel. I
I am experiencing a weird issue with PUT and POST ajax CORS requests in
I am experiencing a very frustrating issue when trying to insert a new record
I am experiencing this problem with Node.js express framework 3.0: https://github.com/visionmedia/express/issues/1187 I've been using
I think I am experiencing a stack overflow issue when running my unit-tests through
I'm experiencing the a challenge in populating the child records. My previous code was
Update: fixed delta calculations in code, still the issue remains Folks, could you please

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.