The problem is that when I select the date and time for the backup, the file handler does not perform its function when finding similar dates

<?php if(isset($_POST['submit'])) { $user_id = $_POST["user_id"]; $name = $_POST["name"]; $time = (int) $_POST["time"]; $date = mysql_real_escape_string($_POST['datepicker']); $newdate = strtotime($date); $newNdate = date('Ym-d', $newdate); $room = $_POST["room"]; $currentTime = (int)date('H'); $CheckQuery = "SELECT * FROM room_reserv WHERE room=1 "; $CheckQueryResult = mysqli_query($connection, $CheckQuery); while($CheckQueryRow = mysqli_fetch_assoc($CheckQueryResult) ){ if($CheckQueryRow['rdate'] == $newNdate){ if($time == $CheckQueryRow['rtime']) { $_SESSION["message"] = "This date has been reserved already!"; }else{ $query = "INSERT INTO room_reserv (user_id , name , rtime , rdate, room) VALUES ('{$user_id}' , '{$name}' ,'{$time}' , '{$newNdate}', '{$room}') "; $result = mysqli_query($connection, $query) or die(mysqli_error($connection)); redirect_to("discussion.php"); } }else{ $query = "INSERT INTO room_reserv (user_id , name , rtime , rdate, room) VALUES ('{$user_id}' , '{$name}' ,'{$time}' , '{$newNdate}', '{$room}') "; $result = mysqli_query($connection, $query) or die(mysqli_error($connection)); redirect_to("discussion.php"); } } } ?> 

Please help me understand what the error

  • Print the $ CheckQueryRow ['rdate'] and $ newNdate values, what's in them? It can not be that initially the dates in different time zones and when formatting to Ymd, one date is in one day and the other in another? In any case, print the values ​​with echo. We do not have your data and it is difficult to reproduce the situation, we need additional information. - cheops
  • In $ CheckQueryRow ['rdate'], the dates that were previously entered when booking from the calendar, and in $ newNdate - the dates that are currently recorded from the calendar ... And I'm trying to check if there are any matches by dates, if there is something to check coincidence in time - pavel
  • Bring to eran values ​​in a loop to render echo $CheckQueryRow['rdate'] . ' ' . $newNdate; echo $CheckQueryRow['rdate'] . ' ' . $newNdate; and show the result - Blacknife

0