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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:12:16+00:00 2026-06-12T09:12:16+00:00

I am struggling to find out why my query is returning zero rows. I

  • 0

I am struggling to find out why my query is returning zero rows. I have extensively tried to figure this out at this question with no decent results.

The jist of it is:

    $mydate=date("Y-m-d",strtotime("-3 months"));

    $foo_query=$DBH->prepare("SELECT * FROM BarTable WHERE postdate = :postdate AND postdate > '$mydate' ORDER BY postdate DESC");
    $foo_query->execute( array('postdate' => $_REQUEST['postdate']) );

EDIT : This query is supposed to say take the date, set it three months in the past, and call it $mydate. Then take all fields from BarTable WHERE the postdate is greater than $mydate, then execute the query.

It has just been pointed out to me that what I have said is that I’m selecting rows where the postdate is equal to 3 months ago and also greater than $mydate.

I don’t understand how I’m saying this. :postdate is not equal to 3 months ago so postdate = :postdate can’t be selecting rows where the postdate is equal to 3 months ago.

To display my rows correctly I was previously typing WHERE postdate > '$mydate'.

How can I type postdate = :postdate AND postdate > '$mydate' so that I am using a parameter and also making sure that data is selected based on being greater than $mydate?

  • 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-12T09:12:16+00:00Added an answer on June 12, 2026 at 9:12 am

    you need to bind the parameter for postdate. also, to get both critierias satisfied, postdate = :postdate and postdate > $mydate, you need to use OR in your query.

    $mydate=date("Y-m-d",strtotime("-3 months"));
    $foo_query=$DBH->prepare("SELECT * FROM BarTable WHERE postdate = :postdate OR postdate > '$mydate' ORDER BY postdate DESC");
    $foo->bindParam(':postdate', $_REQUEST['postdate'], PDO::PARAM_STR);
    $foo_query->execute();
    

    OR similar to what you mentioned in your question, you missed the : when assigning the :postdate,

     $mydate=date("Y-m-d",strtotime("-3 months"));
     $foo_query=$DBH->prepare("SELECT * FROM BarTable WHERE postdate = :postdate OR postdate   '$mydate' ORDER BY postdate DESC");
     $foo_query->execute( array(':postdate' => $_REQUEST['postdate']) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling to find an answer to this theoretical question, even tho
I am sorry for this novice question. I tried to find out difference between
I have been struggling to find out why this rollover is not behaving as
I have been struggling for a few days trying to find out how come
I'm struggling to find a decent walkthrough for this issue, and was hoping that
I have been struggling to find a solution to this problem. In my code,
I'm struggling with trying to find out why this code isn't working for me.
I'm struggling to figure out how to call my named query... @NamedQueries({ @NamedQuery(name =
I am struggling to find out if pushViewController retains the controller, currently I have
This may be an old and trivial question but I have been struggling 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.