[Solved] mysql script not working for date [duplicate]


strtotime is amazingly powerful, but it can’t parse a MySQL date selection syntax. If you want 7 days after last sunday, “sunday” works. You can also do, “last sunday + 7 days”.

I don’t know what $reminder is (are you sure you need to add the date to the reminder variable?), but this will work for your $date variable:

$date = date('Y-m-d',strtotime("sunday"));

As an aside, this is deadly:

$reminder=$_GET['reminder'];
$query = ("SELECT * FROM contacts WHERE reminder="$reminder $date" ".
            " ORDER BY firstname");
            // or die ('Error: ' .mysql_error()); <-- line is always true...

Look up Bobby Tables to understand why that first line should be:

$reminder=mysql_real_escape_string( $_GET['reminder'] );

solved mysql script not working for date [duplicate]