Hey all...
I've got a notices script that I'm working on. The idea is that the user clicks on a date, then that calls an AJAX request to the PHP code that brings out all the events on that date. Here's my query as it stands:
SELECT `notices`.`ID` AS `ID`,
`speakers`.`Name` AS `Name`,
`speakers`.`Website` AS `Site`,
`speakers`.`From` AS `From`,
`notices`.`Date` AS `Date`,
`notices`.`Time` AS `Time`,
`notices`.`Type` AS `Type`,
`notices`.`Calendar` AS `Calendar`,
`venues`.`Name` AS `Venue`,
`notices`.`Created` AS `Created`,
`notices`.`Edited` AS `Edited`
FROM `notices`
JOIN `speakers`
ON `notices`.`Speaker` = `speakers`.`ID`
JOIN `venues`
ON `notices`.`Venue` = `venues`.`ID`
ORDER BY `notices`.`Time` ASC
WHERE `notices`.`Date` = '2010-01-24'
My problem is that I get a MySQL error saying: 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 'WHERE notices.Date = '2010-01-24'' at line 18
If I take out the WHERE, then it works (but I get every notice returned, not just those from the date specified, which is as you'd expect!) or if I take out the ORDER BY then it works fine too, but it sometimes returns multiple events from the same day in the wrong order, for example 10:30 comes before 10:00 and after 13:40.
Like I said, I'm probably just missing something incredibly obvious, but I decided to throw it open on the floor and get some help rather than wasting another hour trying to figure it out.
:o in advance 😉