laPistola Posted November 12, 2011 Share Posted November 12, 2011 MYSQL: 5.1 Hello This is the line of code "SELECT * FROM news WHERE (show >= ".$tdate." AND expire < ".$tdate.") OR (show = 00000000 AND expire < ".$tdate.") AND (show = 00000000 AND expire = 00000000) ORDER BY `order`, title ASC" The error is 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 'show >= 20111112 AND expire < 20111112) OR (show = 00000000 AND expire < 2011111' at line 1 show and expire are both date fields in the DB, $tdate is todays date in the format yyyymmdd Generally I need the record to show if both show and expire = 00000000, If show is of the days date or the date has pasted AND it hasn't gone past the expire date. Also I need the records to show if either date = 00000000 and there show on or expire condition is true. I have gone through many of websites, looked at examples and can't see where my issue is. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 12, 2011 Share Posted November 12, 2011 Show is a MySQL reserved word. EDIT: URL corrected . . . Quote Link to comment Share on other sites More sharing options...
jasonc Posted November 12, 2011 Share Posted November 12, 2011 try the following as see if you get the same error EDITED "SELECT * FROM `news` WHERE (`show` >= ".$tdate." AND `expire` < ".$tdate.") OR (`show` = '00000000' AND `expire` < ".$tdate.") AND (`show` = '00000000' AND `expire` = '00000000') ORDER BY `order`, `title` ASC" Quote Link to comment Share on other sites More sharing options...
laPistola Posted November 12, 2011 Author Share Posted November 12, 2011 Show is a MySQL reserved word. Ah thanks! Quote Link to comment Share on other sites More sharing options...
laPistola Posted November 12, 2011 Author Share Posted November 12, 2011 try the following as see if you get the same error EDITED "SELECT * FROM `news` WHERE (`show` >= ".$tdate." AND `expire` < ".$tdate.") OR (`show` = '00000000' AND `expire` < ".$tdate.") AND (`show` = '00000000' AND `expire` = '00000000') ORDER BY `order`, `title` ASC" News isn't a reserved word as well is it?? It works without me exiting the word news. Thanks anyway! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 12, 2011 Share Posted November 12, 2011 I fixed the link to MySQL's reserved words manual page in my reply above . . . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.