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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:07:02+00:00 2026-06-09T15:07:02+00:00

saw this was an error with incorrect binding (searching stackoverflow), but it looks like

  • 0

saw this was an error with incorrect binding (searching stackoverflow), but it looks like I have all variables bound and no typos…. am I missing the obvious here?

function connect () {
global $pdo;
try {
    $pdo = new PDO("mysql:host=localhost;dbname=test", "root", "root");
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
  }
}

function getPhotos ($status = 0, $type = null, $session = null, $name = null) {
global $pdo;
try {
    $sql = 'SELECT * FROM images WHERE 1=1';

    //Status Filter Query
    $sql .=' AND status = :status';

    //Type Filter Query
    if (!is_null($type)) {
        $sql .=' AND type = :type';
    }

    // Session Filter Query
    if (!is_null($session)) {
        $sql .=' AND session = :session';
    }

    // Twitter Handle Filter Query
    if (!is_null($name)) {
        $sql .=' AND handle = :name';
    }

    //Prepare The Query
    $stmt = $pdo->prepare($sql);

    //Fire The Lasers
    $stmt->execute(array(':status' => $status, ':type' => $type, ':session' => $session, ':name' => $name));

    //Grab 
    return $stmt->fetchAll();
  • 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-09T15:07:03+00:00Added an answer on June 9, 2026 at 3:07 pm

    Only bind the variables when you actually add them to the query:

    //Status Filter Query
    $sql .=' AND status = :status';
    
    $vars = array(':status' => $status);
    
    //Type Filter Query
    if (!is_null($type)) {
        $sql .=' AND type = :type';
        $vars[':type'] = $type;
    }
    
    // Session Filter Query
    if (!is_null($session)) {
        $sql .=' AND session = :session';
        $vars[':session'] = $session;
    }
    
    // etc.
    
    $stmt->execute($vars);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this topic and implement IntentService as describes, but what if I want
I saw this similar question here but can't figure out how to use Contains
I've been working on PHP for some time but today when I saw this
I saw this question Simple example of threading in C++ but my problem is
When i try to debug using Firebug , i saw this 414 error. In
I have got this error message: #2002 - The server is not responding (or
I have this problem with Headers already sent with Magento. I get this error:
i create 3 module for my proj like this: application/module/admin application/module/default application/module/error every module
So, I saw this: error:(NSError **)error in the apple doc's. Why two stars? What
Recently i saw this piece of code. Shouldnt this line be a compile error?

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.