I’m trying to select a list of events from a database with MySQL. I’m fairly new to php but usually I can figure stuff out. cant seam to get this to work though..
function get_events_within_dates($da,$dd) {
global $connection;
$query = "SELECT *
FROM events
WHERE date
BETWEEN STR_TO_DATE('$da','Y-m-d') AND STR_TO_DATE('$dd','Y-m-d')
ORDER BY date ASC";
I’ve used $da and $dd as date of arrival and date of departure..
I can get it to work fine when I replace the variables with exact dates, tried messing around with STR_TO_DATE() and that didn’t help either. Any help appreciated.
You are missing
%in the format string. UseSTR_TO_DATE()as:Full query as below: