timmah1 Posted December 18, 2008 Share Posted December 18, 2008 What is the right way to write this $time = date("Y-m-d H:i:s"); $sql1 = "SELECT * FROM specials WHERE sport = 'ncaab' AND date("Y-m-d H:i:s", strtotime($time)) BETWEEN 'start' AND 'end'"; I get the message that the Query was empty Thanks in advance Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Author Share Posted December 18, 2008 Sorry, this code $sql1 = 'SELECT * FROM specials WHERE sport = "ncaab" AND ".date('Y-m-d H:i:s')." BETWEEN "start" AND "end"'; mysql_query($sql) or die("Sorry, there was a problem creating the specials ".mysql_error()); Quote Link to comment Share on other sites More sharing options...
twm Posted December 18, 2008 Share Posted December 18, 2008 what is the date field name? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 18, 2008 Share Posted December 18, 2008 If that is your actual query string and your query, it is going to be kind of hard to get mysql to perform a query using $sql, when the variable name you have put the query string in to is named $sql1 Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Author Share Posted December 18, 2008 That was a typo PFMaBiSmAd I'm trying this, and it isn't working $sql1 = "SELECT * FROM specials WHERE sport = 'ncaab'"; $q1 = mysql_query($sql1); while($a = mysql_fetch_assoc($q1)){ if($time > $a['start'] "AND" $time < $a['end']){ echo $a['name']; } else { echo Try Again; } Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 18, 2008 Share Posted December 18, 2008 this: if($time > $a['start'] "AND" $time < $a['end']){ should be: if($time > $a['start'] && $time < $a['end']){ and also make sure that $time holding correct value. Quote Link to comment Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Author Share Posted December 18, 2008 I have time like this $time = date("Y-m-d H:i:s"); Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted December 18, 2008 Share Posted December 18, 2008 Can you post your complete code. 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.