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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:02+00:00 2026-06-18T12:33:02+00:00

I use PDO for my project, so i don’t know why my function return

  • 0

I use PDO for my project, so i don’t know why my function return nothing…

function getuser($username) {
    require 'database.php';
    $rep = $bdd->prepare("SELECT * FROM membre where login =:user");
    $rep =$bdd->execute(
        array(
            'user'=>$username
            ));

        while($row = $rep->fetch(PDO::FETCH_OBJ)) {
            //$userid = $row->id;
            //$usermail = $row->email;
            echo $row->id;
        }
}

and usage:

$uname = $_SESSION['uname'];
echo $uname;
//result: kate
echo getuser($uname);
//result:

I don’t know Why it’s not work?

  • 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-18T12:33:03+00:00Added an answer on June 18, 2026 at 12:33 pm

    You have an error. Code should be:

    $rep = $bdd->prepare("SELECT * FROM membre where login =:user");
    $rep->execute(
        array(
            'user'=>$username
            ));
    

    Basically, $rep is a statement. You prepare() a statement and then execute it. Right now you run execute on the wrong object.

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

Sidebar

Related Questions

I'm reworking some PHP code to use PDO for the database access, but I'm
Should I use php PDO or normal mysql_connect to execute database queries in PHP?
I want to select a MySQL database to use after a PHP PDO object
Possible Duplicate: Anyone know of a good PHP ORM that DOES NOT use PDO?
I'm experimenting with PHP's session_set_save_handler and I'd like to use a PDO connection to
I've been using the DBLib PDO driver for connecting my PHP Symfony project with
I have a function that I found that was wrote to use PDO, I
I want to know when and where we use PDO's other than simple mysql_connect
Hi I am using a PHP Symfony project and am trying to use the
should i use php's htmentities() with pdo to filter input and output escapeing, to

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.