School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,217 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,617 people online right now. Registration is fast and FREE... Join Now!




Trouble forming MYSQL query properly

 

Trouble forming MYSQL query properly

jeffmc21

25 Aug, 2009 - 09:54 AM
Post #1

D.I.C Head
**

Joined: 27 Nov, 2007
Posts: 62


My Contributions
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 have:
CODE

// 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>&nbsp;&nbsp;'.$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 &lt; CURRENT_TIME() LIMIT 1' at line 1
Whole query:

User is offlineProfile CardPM
+Quote Post


Posts in this topic

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:15PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month