Reputation:
another dumb question to brighten your day. I have this MySql query and, yes, it doesn't shown any result. What's wrong here? Is it the AND or the ORDERBY? hmmm...
SELECT * FROM statisticData WHERE SYear LIKE '$SYr' AND accessDate BETWEEN '$startDate' AND '$endDate' ORDER BY accessDate DESC
Oh, this is what comes before the query:
$SYr = $_POST['SYr'];
$startDate = date("m-d-Y", strtotime($_POST['Date1']));
$endDate = date("m-d-Y", strtotime($_POST['Date2']));
Upvotes: 0
Views: 53
Reputation: 324720
Dates in MySQL must be in Y-m-d
format. m-d-Y
is not acceptable and will not return any rows.
Also:
Escape your inputs. Its okay for the date ones because you're handling them already and the output is a PHP-generated date. But $SYr
is currently unsafe.
Upvotes: 2