I get the DATE variable from the Datepicker Jquery UI and include it as variable in the MYSQL statement. But select does not work with the variable. What reason ?
Below the code
$fromDate = new DateTime($from);
$toDate = new DateTime($to);
$fromDate2 = mysqli_real_escape_string($fromDate);
$toDate2 = mysqli_real_escape_string($toDate);
$sql = mysqli_query($mySqlConnect,"SELECT * FROM 1398_log WHERE date BETWEEN $fromDate2 AND $toDate2 ORDER by id DESC");
This select OK:
$sql = mysqli_query($mySqlConnect,"SELECT * FROM 1398_log WHERE date BETWEEN '2016-03-01 00:00:00' AND '2016-06-30 23:59:59'ORDER by id DESC");