Is my syntax correct?
Posted: Sun Nov 02, 2008 10:15 am
I'm using PHP & MySQL to select a blog entry based on it's publish date. I've omitted the unneeded code. Will the part where it says "WHERE date = $today" work or do I need to wrap $today with single or double quotes?
Code: Select all
$today = date("Y-m-d h\:i\:s");
$result = mysql_query("SELECT * FROM blogEntries WHERE date = $today");
if (!$result) {
die('There was an error with MySQL: ' . mysql_error());
}
$row = mysql_fetch_row($result, MYSQL_ASSOC);