php - mysqli not reading the AND / OR statement correctly -


i have problem regarding retrieving data database, mysqli disregarding , statement code.

$query_check = "select * databasetime          (authid='".$database->real_escape_string($_session['profile']['authid'])."' ,          userid = '".$database->real_escape_string($_post['contact'])."') , (         fromdatetime >= '".$database->real_escape_string($_post['fromdate'].' '.$fromtime)."' ,          fromdatetime <= '".$database->real_escape_string($_post['todate'].' '.$totime)."') or         (fromdatetime <= '".$database->real_escape_string($_post['fromdate'].' '.$fromtime)."' ,          fromdatetime >= '".$database->real_escape_string($_post['todate'].' '.$totime)."') or          (todatetime >= '".$database->real_escape_string($_post['fromdate'].' '.$fromtime)."' ,          todatetime <= '".$database->real_escape_string($_post['todate'].' '.$totime)."'))";          $result_check = $database->query( $query_check );            $row_check = $result_check->fetch_object();      if(!$row_check)         echo valid;     else         echo invalid; 

the query should check if authid , userid match seems disregard when making call database

please tell me if i'm doing correctly..

what i'm trying this:

the |....| represents time frame each user id ex: 3:00am - 5:00am

=========================================================================== user id: 5 ------------------|.......................|---------------- base user id: 5 ------------------|.......................|---------------- invalid user id: 5 |.......................|---------------------------------- invalid user id: 5 ----------------------------|.......................|------ invalid user id: 5 |.........|------------------------------------------------ valid user id: 5 ------------------------------------------|.........|------ valid user id: 6 |.......................|---------------------------------- valid user id: 6 ----------------------------|.......................|------ valid user id: 6 ------------------|.......................|---------------- valid 

update changed few lines on code based on suggestions comment:

this problem have right now:

=========================================================================== user id: 5 ------------------|.......................|---------------- base user id: 5 ------------------------------------------|.............|-- valid 

instead of printing valid it's giving me invalid.

when remove ( = ) query problem

=========================================================================== user id: 5 ------------------|.......................|---------------- base user id: 5 ------------------|.......................|---------------- invalid 

instead of printing invalid it's giving me valid.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -