I am trying to see if a field (end_date) in a MySQL database in the form of 2015-6-11 21:28:02 is greater than the current time. Essentially, is that field in the future or not.
Here is my PHP Code:
$current_time = time();
$sql = "SELECT member_id, course_id, FROM ".TABLE_PREFIX."vbc_status WHERE end_date < NOW()";
$result = mysql_query($sql, $db);
while ($row = mysql_fetch_assoc($result)) {
$echo $row['member_id'];
}
I keep getting an error:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /path/to/script.php on line 373.
Line 373 is the while ($row = mysql_fetch_assoc($result)) { part.
Any ideas of how this should be fixed?
mysql_query, aren't you? You're calling that function incorrectly, wrong arguments, the query string itself is probably fine. Keep in mind a modern database driver like PDO is not hard to learn. A guide like PHP The Right Way can help explain best practices.