jeffmc21
08-25-2009, 06:56 PM
I'm having trouble forming the query to my database properly to retrieve the info I'm needing. All I'm trying to get is a single result where the DAY column of the DB is the same as today's day name and the START column (which is a time field) is less than the current time.
Here's the code I'm using:
// Query the DB and retrieve the program information from the table
$result = mysql_query("SELECT * FROM `programming` WHERE DATE = DAYNAME() AND START < CURRENT_TIME() LIMIT 1");
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<p class="now"><strong>On Air Now:</strong> '.$row["NAME"].'<br />'.$row["HOST"].'</p>';
}
?>
And here's the error message I'm getting:
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND START < CURRENT_TIME() LIMIT 1' at line 1
Whole query:
Here's the code I'm using:
// Query the DB and retrieve the program information from the table
$result = mysql_query("SELECT * FROM `programming` WHERE DATE = DAYNAME() AND START < CURRENT_TIME() LIMIT 1");
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result)) {
echo '<p class="now"><strong>On Air Now:</strong> '.$row["NAME"].'<br />'.$row["HOST"].'</p>';
}
?>
And here's the error message I'm getting:
Invalid query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND START < CURRENT_TIME() LIMIT 1' at line 1
Whole query: