rubing Posted March 17, 2008 Share Posted March 17, 2008 I am trying to retrieve a set of results from a mysql within a specified date range. My original query without specifying the date range worked fine! However when I introduced the BETWEEN statement (incl. $POST arrays) it stopped working. Now, I get no results!! Anybody have a clue?? $query_str = "SELECT DISTINCT MusicEvents.Band,BandSite FROM MusicEvents LEFT JOIN Bands ON MusicEvents.Band=Bands.Band WHERE BandSite IS NULL BETWEEN '". $_POST['startdate'] ."' AND '". $_POST['enddate']. "' ORDER BY Date ASC, MusicEvents.Band ASC"; Quote Link to comment Share on other sites More sharing options...
nibbo Posted March 17, 2008 Share Posted March 17, 2008 I think you need another AND in there... WHERE BandSite IS NULL AND whateverdate BETWEEN ... Quote Link to comment Share on other sites More sharing options...
rubing Posted March 17, 2008 Author Share Posted March 17, 2008 I'm afraid that didn't make a difference Quote Link to comment Share on other sites More sharing options...
rubing Posted March 17, 2008 Author Share Posted March 17, 2008 I just tried adding in the command manually and it didn't work...hmmmm Quote Link to comment Share on other sites More sharing options...
teng84 Posted March 17, 2008 Share Posted March 17, 2008 what is the error message? Quote Link to comment Share on other sites More sharing options...
rubing Posted March 17, 2008 Author Share Posted March 17, 2008 AHHHH YES, I forgot...I had error messages suppressed. Let's see, the error message is: Fatal error: Call to a member function fetch_assoc() on a non-object in /home/rubing/public_html/exec/yahoo.php on line 47 Quote Link to comment Share on other sites More sharing options...
rubing Posted March 17, 2008 Author Share Posted March 17, 2008 $query_str = "SELECT DISTINCT MusicEvents.Band,BandSite FROM MusicEvents LEFT JOIN Bands ON MusicEvents.Band=Bands.Band WHERE BandSite IS NULL AND BETWEEN '". $_POST['startdate'] ."' AND '". $_POST['enddate']. "' ORDER BY Date ASC, MusicEvents.Band ASC"; $result = $conn->query($query_str); while(($row = $result->fetch_assoc()) !==NULL ) //This is LINE 47 { Quote Link to comment Share on other sites More sharing options...
rubing Posted March 17, 2008 Author Share Posted March 17, 2008 I think I just forgot to put in the date column... YES BROTHERS... WE solved it. First of all, i stupidly omitted the date collum before the BETWEEN COMMAND Secondly, there needed to be another AND statement as follows: $query_str = "SELECT DISTINCT MusicEvents.Band,BandSite FROM MusicEvents LEFT JOIN Bands ON MusicEvents.Band=Bands.Band WHERE BandSite IS NULL AND Date BETWEEN '". $_POST['startdate'] ."' AND '". $_POST['enddate']. "' ORDER BY Date ASC, MusicEvents.Band ASC"; 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.