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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:31:12+00:00 2026-06-15T11:31:12+00:00

I am having a wierd issue on a query, I am simply doing a

  • 0

I am having a wierd issue on a query, I am simply doing a search using 2 dates, I have all the dates in the database formatted in 2012-12-02 00:00:00 mysql format, but it is simply ignoring the AND cslblicstat = ’10’ AND wcxdate BETWEEN ‘$date1’ AND ‘$date2’ and giving me anything that has the matching class.

$user = $session->username;
if(isset($_POST['carrier'])){
$carrier = $_POST['carrier'];
$class[] = $_POST['class'][0];
$date1 = $_POST['date1'];
$date1 = date("Y-m-d 00:01", strtotime($date1));
$date2 = $_POST['date2'];
$date2 = date("Y-m-d 59:59", strtotime($date2));

 foreach( $class as $key){
 $query =   "SELECT * FROM leads WHERE class1 = '$key' OR class2 = '$key' OR class3 = '$key' OR class4 = '$key' OR class5 = '$key' OR class6 = '$key' OR class7 = '$key' OR class8 = '$key' OR class9 = '$key' OR class10 = '$key' OR class11 = '$key' OR class12 = '$key' AND user = '' AND wccompcode = '$carrier' AND cslblicstat = '10' AND wcxdate BETWEEN '$date1' AND '$date2' LIMIT 100";
$sellead = mysql_query($query)or die(mysql_error());
while($leads = mysql_fetch_array($sellead)){

    $arrayl[] = $leads;
    $rowid = $leads['ID'];
    $update = mysql_query("UPDATE leads SET user = '$user' WHERE ID = '$rowid'")or die(mysql_error());

}
}
}
  • 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-15T11:31:13+00:00Added an answer on June 15, 2026 at 11:31 am

    In SQL, AND operator has higher precedence than OR. I guess that you just need to put the ORed conditions into parentheses:

    SELECT * 
    FROM leads
    WHERE (class1 = '$key' OR class2 = '$key' OR ... OR class12 = '$key')
      AND user = '' 
      AND wccompcode = '$carrier' 
      AND cslblicstat = '10' 
      AND wcxdate BETWEEN '$date1' 
                      AND '$date2' 
    LIMIT 100   
    

    When in doubt about precedence of operators, use parenthesis (or consult the manual).

    You could also write that condition with IN:

    WHERE '$key' IN (class1, class2, ... , class12)
      AND user = ''
      ---
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having a wierd issue that is driving me absolutely crazy. It
I am having some weird issue here. I have a database table which has
I'm having an odd issue in FF10 using jQuery 1.7.1. I have a gallery
I am using SQL Server 2000 and having a wierd issue with a SQL
I am having a weird issue with PDO when I query a DB2 database
I'm having this wierd issue with my log4JAppender. Im using a dailyRollingFileAppender and the
I am having a weird issue with nuget.exe command line tool. I have a
I am having a weird issue in MVC. I am using ASP.Net MVC, I
Having a weird issue with Rails 3.2.1. Working with a legacy database with icky
I am having a weird issue with my profiles. For my project, i have

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.